View Single Post
Old 07-07-2010, 06:40 PM   #2 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

The best way to make sure the right path is used, is to provide an absolute one. Commonly that means using something like __DIR__ (or dirname(__FILE__) if you're not blessed with being able to use PHP 5.3 yet) to get the absolute path to the file the constant is written in.

For example, inside your head.php file:

PHP Code:
include __DIR__ '/../Admin/Docs/head.txt'
If the path to head.php was /home/path/to/site/includes/head.php then __DIR__ would be /home/path/to/site/includes. That would make the included file be located at /home/path/to/site/includes/../Admin/Docs/head.txt which is just the same as /home/path/to/site/Admin/Docs/head.txt.

With that, you would continue including the head.php as you are and the path would always be correct for the head.txt file.
Salathe is offline  
Reply With Quote
The Following User Says Thank You to Salathe For This Useful Post:
Tim Dobson (07-08-2010)