Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2005
    Posts
    30
    Thanks
    0
    Thanked 1 Time in 1 Post

    Simple PHP include() Question

    I've got a simple question about the include function. I've searched the web and found different, unclear answers and searched the forums and found no results. In order to use the include("") function to insert a menu/header into my pages, does the file have to be in the same directory? I've experimented with it and can't find a way to get it to work.

    Any help is appreciated.

  • #2
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,043
    Thanks
    19
    Thanked 42 Times in 42 Posts
    it doesnt have to be in the same directory
    PHP Code:
    include(./page.inc); 
    //will take it back or up on level in the directory 
    need to no more check the official manual at www.php.net/include.php
    or ask here

  • #3
    New Coder
    Join Date
    Oct 2005
    Posts
    30
    Thanks
    0
    Thanked 1 Time in 1 Post
    Is it possible to link it back up to the root directory? I've messed around with it a few different ways, but nothing has worked. I tried:
    PHP Code:
    <?php include("/phpincludes/menu.txt")?>
    menu.txt is, of course, in the directory phpincludes at the root of my site. Is there a different way to do this?
    Last edited by boko; 06-04-2007 at 01:27 AM.

  • #4
    Senior Coder rafiki's Avatar
    Join Date
    Aug 2006
    Location
    Floating around somewhere...
    Posts
    2,043
    Thanks
    19
    Thanked 42 Times in 42 Posts
    Quote Originally Posted by boko View Post
    Is it possible to link it back up to the root directory? I've messed around with it a few different ways, but nothing has worked. I tried:
    PHP Code:
    <?php include("/phpincludes/menu.txt")?>
    menu.txt is, of course, in the directory phpincludes at the root of my site. Is there a different way to do this?
    $_SERVER['DOCUMENT_ROOT']/phpincludes/menu.txt <= include that


  •  

    Posting Permissions

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