Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

[1826] Simple PHP includes

Last post 09-05-2004 9:02 PM by AR. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 01-01-1999 12:00 AM

    [1826] Simple PHP includes

    This thread is for discussions of Simple PHP includes.

    • Post Points: 0
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 01-18-2003 4:46 AM In reply to

    • lowt
    • Not Ranked
    • Joined on 01-18-2003
    • New Member
    • Points 5

    great tutorial!

    Hi!

    Thanks for the great tutorial! It really helped me a lot.
    One question still:
    If i want include more than 1 (txt)file with just 1 link, (for instance text1.txt in tablecell A, and text2.txt in Table cell B, and perhaps a picture in Table cell C) how do i put that in the hyperlink?

    Hope you can help me out on this one.

    Thanks again!
    • Post Points: 0
  • 01-22-2003 11:41 AM In reply to

    • hamilte
    • Not Ranked
    • Joined on 01-22-2003
    • New Member
    • Points 15

    How to use Virtual Path with Includes

    I'm new to PHP and would like to use virtual paths for my PHP includes like I do in ASP:

    <!--#include virtual="/common/myinclude.asp"-->

    I've tried:

    <$ include ("/common/myinclude.php") ?>

    I get an error message "Unexpected T_INCLUDE at line 3..."

    Thanks!

    Liz
    PS Your tutorial is well written. You'll have a book contract before long!
    • Post Points: 0
  • 01-22-2003 2:36 PM In reply to

    • hamilte
    • Not Ranked
    • Joined on 01-22-2003
    • New Member
    • Points 15

    Problem Solved

    I discovered that the virtual root of my Web account was different from what I thought it was.

    The root starts several directories below where I thought it started.

    I'm new to the particular hosting service where my site is!

    Thanks again.

    Liz

    • Post Points: 0
  • 03-08-2003 3:10 PM In reply to

    Fools...

    Oh, yeah, what a great tutorial - not! There's no security whatsoever and its capability is low. So, if you're smart (Not to mention a master PHP coder *Hint Hint*), use the following:

    Code:

    <?php
       if(!empty($HTTP_GET_VARS[page]) and file_exists("./$HTTP_GET_VARS[page].inc")) {
           include("./$HTTP_GET_VARS[page].inc");
       } else {
           include("./main.inc");
       }
    ?>


    The include will be main.inc if the variable page is not defined. Now, you can make all your content with a .inc extension and include it with the one page that has this code. For links, use http://yoursite/index.php?page=NameOfPage.inc

    There you go.
    • Post Points: 0
  • 03-29-2003 3:36 PM In reply to

    • thoma05
    • Not Ranked
    • Joined on 03-29-2003
    • New Member
    • Points 5
    Quote:
    [1]Posted by Zidane-Tribal on 8 Mar 2003 03:10 PM[/1]
    The include will be main.inc if the variable page is not defined. Now, you can make all your content with a .inc extension and include it with the one page that has this code. For links, use http://yoursite/index.php?page=NameOfPage.inc

    There you go.


    FYI, I thought the original tutorial was helpful but what Zidane added is certainly more practical (eventhough his tone was unnessecary).  Anyway, slight correction.  To reference the pages, you would use http://yoursite.index.php?page=NameOfPage   (no need for the .inc).

    Enjoy!
    • Post Points: 0
  • 04-09-2003 11:24 AM In reply to

    • fame
    • Not Ranked
    • Joined on 04-09-2003
    • New Member
    • Points 5
    zidane,

    your reply was so helpful, that i've built a site around it and registered just to thank you.

    so... thank you.  



    fame
    • Post Points: 0
  • 07-10-2003 7:50 PM In reply to

    • PHPeep
    • Not Ranked
    • Joined on 07-10-2003
    • New Member
    • Points 5

    Security Not an Issue?

    If security is not an issue, what is wrong with simply making you header, footer, sidebar content as .txt includes for example and just use the <?php ;?> where you want them to show up in your .php files that contain main content?
    Also, where can I go to learn how to manage the whole site with PHP? I find a lot of stuff is either too hard to understand or doesn't explain all the terms it uses.
    • Post Points: 0
  • 09-12-2003 4:19 PM In reply to

    • shizuka
    • Not Ranked
    • Joined on 09-12-2003
    • New Member
    • Points 5

    What about caching?

    I gave the "corrected" code a try, but I'm using Javascript rollovers in the menu bar and now the buttons pause before loading, even though the script preloads them--and not only that, but it does that for every "page" in the site.



    Is there any way to check for cached versions of my preloaded buttons so it doesn't have to load them fresh for every page?  Maybe some kind of If-Then-Else instead of using the Code:
    <? include("menu.inc") ?>
    ???

    Shizuka
    • Post Points: 0
  • 09-03-2004 5:53 PM In reply to

    include example with half instructions incomplete

    email me , a your instructions as follows  just gives you a name for the first page when creating your example for the first half of the code but what about the second half of the code with the other half of the table what do you name it and on the third part of the code you dont say what to name it either, i am a newbie and and reading your instructions for this example loses me real quick cause you leave most of it out this intruction and wher to put or use the link in php??? im lost for a newbie can u give plain er instructions please php for dummies, lol
    • Post Points: 0
  • 09-05-2004 9:02 PM In reply to

    • AR
    • Not Ranked
    • Joined on 09-05-2004
    • New Member
    • Points 10

    php includes

    Try using this:

    include $_SERVER[DOCUMENT_ROOT]."/common/yourfile.php";

    This should do it.

    Breckenridge Guy!
    • Post Points: 0
Page 1 of 1 (11 items)