guttyguppy Posted July 24, 2007 Share Posted July 24, 2007 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. Quote Link to comment Share on other sites More sharing options...
trq Posted July 24, 2007 Share Posted July 24, 2007 include $_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'; Quote Link to comment Share on other sites More sharing options...
guttyguppy Posted July 24, 2007 Author Share Posted July 24, 2007 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.