Welcome to Discuss Everything Forums...

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.


 

Tags for this Thread

+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    echo "<html><font color=\"red\">Hi</font>";

    require_once();
    require()
    include_once()
    include()

  2. #2
    Nosferatu's Avatar
    Junior Member

    Status
    Offline
    Join Date
    May 2009
    Posts
    9
    Downloads
    0
    Uploads
    0

    php question about embedding php?

    ok, i know how to embed html into a php page but how to i embed another php page into it without copying the main source code? can anybody tell me source code? kinda like iframes for php? maybe i could try changing to html in the coding, then using an iframe to embed the other php page? thanks

  3. #3
    jason c's Avatar
    Junior Member

    Status
    Offline
    Join Date
    May 2009
    Posts
    25
    Downloads
    0
    Uploads
    0
    I think this is what you mean:

    <?php
    include 'page.php';
    ?>

  4. #4
    Chris B's Avatar
    Senior Member

    Status
    Offline
    Join Date
    May 2009
    Posts
    236
    Downloads
    0
    Uploads
    0
    Nah, Jason has the right idea. Here's an example with both:
    <?php
    echo "<html>
    <body>
    <p> This is HTML in PHP file!</p>";
    include("./somepage.php");
    ?>

    inlclude("file_source"); is the code you use to add all the script inside a different PHP file to the current one.
    the includeis like a <script type='text/javascript' src='file_source'> which brings JAVASCRIPT from a different .js file to the current one.

    Best answers always appreciated.

  5. #5
    Colin W's Avatar
    Junior Member

    Status
    Offline
    Join Date
    May 2009
    Posts
    8
    Downloads
    0
    Uploads
    0
    PHP pages are not really PHP pages they are PHP + HTML Pages. If you wanted the title of a page to be a variable you could do:

    <?php
    $helloworld = "23";
    ?>

    <html>
    <head>
    <title>
    <?php
    echo $helloworld;
    ?>
    </title>
    </head>
    <body>
    </body>
    </html>

    Just use the php tags (<?php and ?>) to open and close sections of php code and the rest is pure html.

    to embed a different file use either:

    include("myfile.php");

    or

    require("myfile.php")

    only difference is in how they handle errors.

  6. #6
    Colin W's Avatar
    Junior Member

    Status
    Offline
    Join Date
    May 2009
    Posts
    8
    Downloads
    0
    Uploads
    0
    PHP pages are not really PHP pages they are PHP + HTML Pages. If you wanted the title of a page to be a variable you could do:

    <?php
    $helloworld = "23";
    ?>

    <html>
    <head>
    <title>
    <?php
    echo $helloworld;
    ?>
    </title>
    </head>
    <body>
    </body>
    </html>

    Just use the php tags (<?php and ?>) to open and close sections of php code and the rest is pure html.

    to embed a different file use either:

    include("myfile.php");

    or

    require("myfile.php")

    only difference is in how they handle errors.

 

 

Quick Reply Quick Reply

Click here to log in


What is the sum of 36 and 12

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Embedding html in php file?
    By obsidian in forum Discuss HTML
    Replies: 0
    Last Post: 02-27-2011, 04:03 AM
  2. Embedding PHP in JavaScript?
    By David Olivas in forum Discuss PHP
    Replies: 0
    Last Post: 12-21-2010, 04:20 AM
  3. Replies: 0
    Last Post: 02-02-2010, 06:40 AM
  4. Replies: 0
    Last Post: 01-25-2010, 10:26 PM
  5. Replies: 0
    Last Post: 01-15-2009, 12:49 AM

Bookmarks

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •