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.


 

Reply to Thread

Post a reply to the thread: php question about embedding php?

Your Message

Click here to log in

What is the number after 87?

 
 

You may choose an icon for your message from this list

Additional Options

  • Will turn www.example.com into [URL]http://www.example.com[/URL].

Rate Thread

You may rate this thread from 1-star (Terrible) to 5-stars (Excellent) if you wish to do so.

Topic Review (Newest First)

  • 05-24-2009, 07:35 PM
    Colin W
    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.
  • 05-24-2009, 07:35 PM
    Colin W
    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.
  • 05-24-2009, 07:33 PM
    Chris B
    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.
  • 05-24-2009, 07:32 PM
    jason c
    I think this is what you mean:

    <?php
    include 'page.php';
    ?>
  • 05-24-2009, 07:32 PM
    Nosferatu

    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
  • 05-24-2009, 07:32 PM
    DzSoundNirvana
    echo "<html><font color=\"red\">Hi</font>";

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

Posting Permissions

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