View Single Post
07-08-2010, 10:43 PM   #3 (permalink)
Tim Dobson
The Contributor

Join Date: Feb 2010
Posts: 69
Thanks: 16

Quote:
 Originally Posted by Salathe 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.
ok i think i am with you but i failed to get that to work so i thought i would try something like

PHP Code:
 <?php                      $myFile = "E:\domain\link\sb0t.tentun.co.uk\goin\to\the\file\head.txt";$fh = fopen($myFile, 'r');$theData = fread($fh, filesize($myFile)); fclose($fh); echo '' .$theData . ''; ?> 
Which correct me if i am wrong would do vertualy the same thing?

It is getting the absolute path and then printing out the data from the file. Atleast it seems to work for me doing it such a way.