#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    23
    Rep Power
    0
    How do I include a file that contains PHP code (that must be processed) into another PHP file?

    If I use include(), the code will not be parsed. I hope this is possible.

    For example (a page):

    <?php
    $blah = "blch"
    $kjk = "jkdfj"

    //include PHP code here

    if($dkfjsdlf = "sdfsd") {
    $jkfj = "skdlfjs"
    }
    ?>


    Please Help.
  2. #2
  3. No Profile Picture
    Nightwork
    Guest
    Devshed Newbie (0 - 499 posts)
    I usually use server side includes in the html source:

    <!--#include file="index.inc" -->

    index.inc is the php/html source I want to be included, works fine with me. But the server needs to support ssi.

    (for some more info: http://htmlgoodies.earthweb.com/beyond/ssi.html)

    And maybe there's an solution using include() as well, I never tried that.

    Jeroen
  4. #3
  5. Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2000
    Location
    Enschede, The Netherlands
    Posts
    1,527
    Rep Power
    16
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>And maybe there's an solution using include() as well, I never tried that.[/quote]

    Yup, you can use include() to to the job

    mirax1.php:

    <?php
    include( "mirax_header.php" );
    print( "Hi!" );
    include( "mirax_footer.php" );
    ?>

    where mirax_header.php and mirax_footer.php look like:

    <?php // it is needed to put the <?php in the including file also!!
    print( "<html><body>" ); // etc...
    ?>

    This way, the code will be parsed, at least is does with me
    Hope this helps!

Similar Threads

  1. Replies: 3
    Last Post: February 17th, 2004, 10:08 AM
  2. How to write a PHP script to remove a file?
    By xmxpcom in forum PHP Development
    Replies: 2
    Last Post: February 16th, 2004, 05:58 PM
  3. Pointer problem in opening a file
    By LAKI in forum C Programming
    Replies: 13
    Last Post: February 11th, 2004, 08:27 AM
  4. Pointer problems opening file *formatted*
    By LAKI in forum C Programming
    Replies: 4
    Last Post: February 11th, 2004, 06:06 AM
  5. Replies: 1
    Last Post: February 5th, 2004, 09:38 AM

IMN logo majestic logo threadwatch logo seochat tools logo