Jump to content

Directories and includes


guttyguppy

Recommended Posts

Hi, I'm sure this is a common question but I can't seem to find anything relevant. If I have my header and footer includes in an includes directory, and all my web pages are using them, and all my web pages are inside various directories and sub directories, how can I use one code snippet to access the includes? I've always just done

 

include "http://www.domainname.com/includes/header.php"

 

but I get the feeling there is something better than that, plus if I move my code to different servers I have to change that on every page.

 

Thanks for any advice.

Link to comment
https://forums.phpfreaks.com/topic/61559-directories-and-includes/
Share on other sites

Thanks, but that returns /var/www on my server, but my site is in /home/username/public_html/

 

My site is one of these deals:

 

http://www.domainname.com/~username

 

Also, I thought $_SERVER['DOCUMENT_ROOT'] returns a string, so wouldn't the page look for a sibling directory called /var instead of going to the root?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.