note 57822 deleted from function.include by aidan
| From: | aidan@php.net | Date: | Sat, 15 Apr 2006 16:30:00 +0000 |
| Subject: | note 57822 deleted from function.include by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-108152@lists.php.net to get a copy of this message | ||
Note Submitter:
----
A problem you might be having is if you include a file from one directory and then that file in turn
includes another file in yet another directory (relative to its current position). If you are
experiencing this problem you need a work around.
Eg, File A.php located in directory 'somedir' includes file B.php located in
'somedir2'. File B.php includes file C.php which is located in 'somedir3'. For
this example 'somedir' contains both 'somedir2' and 'somedir3'.
A.php's include statement:
-------
include("somedir2/B.php"); //Works fine...
-------
B.php's include statement:
-------
include("../somedir3/C.php"); //Doesn't work when included in A.php
-------
So a work around is needed. One option is to use the work around provided by "rainfalling at
yahoo dot com" or, you could use the following adaptation of that example:
B.php's include statement that will work all the time:
-------
$pathFix = dirname(__FILE__);
include("$pathFix/../somedir3/C.php"); //Works all the time...
-------