SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast cadmium's Avatar
    Join Date
    Jan 2006
    Location
    York, PA
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to include the same files in different directories?

    I need to include the same files on every page in all subdirectories. I wish not to use the complete path because I don't want to have to update the include on every page when I upload it to the web.

    Any suggestions?

  2. #2
    SitePoint Zealot sidhighwind's Avatar
    Join Date
    Aug 2003
    Location
    Indianapolis, IN
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just do something like this:

    PHP Code:
     require_once('../../includes/includeme.php');
     -or-
     require_once(
    '../includes/includeme.php'); 
    Or What you could do is put the path to your include files in your php.ini file under the include_path varable and then you would just have to do this:

    saying that your include_path variable has your path to your include directory in it.

    PHP Code:
    require_once('includeme.php'); 
    Jon Whitcraft :: It's the Bombdiggity!
    Web Applications Developer :: Zend Certified Engineer
    http://www.indycar.com

  3. #3
    SitePoint Enthusiast cadmium's Avatar
    Join Date
    Jan 2006
    Location
    York, PA
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you.

  4. #4
    SitePoint Enthusiast cadmium's Avatar
    Join Date
    Jan 2006
    Location
    York, PA
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm prepending the links with "../" and it seems to be working fine except for the style sheet. I am linking to an external style sheet via the link "../style.css" which is in the main directory. This is contained inside "header.php." It works fine in all of the sub directories but it does not work on the index.php page. I could just copy and past the content of the header into index.php and change the stylesheet link, but I'm sure there's another way.


Bookmarks

Posting Permissions

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