There must be something i don\'t understand about linking files -- but here\'s my problem.
Basically, i have three files.
I've going to take the mathematical approach. PHP always includes additional files from the current working directory, not the current file being included.
So if we are in file C (index.php), we are on level 4. File C includes file B which is in the parent directory (according to the ../
) which will be on level 3.
Now file B is included inside file C (with extra emphasis on inside). We are still working from level 4, not level 3. So when you attempt to include file A, we're technically include file A inside file C, not inside file B, so the path is only going up 3 directories instead of the 4 directories it needs to go up through.
Thus when we are executing file B, which is on level 3, include file A will go up three levels to level 0, which is the appropriate place to look for the file.
I'd suggest using absolute paths to access all files because using relative paths only causes problems, such as the one you have found yourself in here.
The way I do it is set a 'root' variable that is accessible throughout all my scripts, for use to define absolute paths. I put it in my index.php file since that is the only file that is ever run.
$ani->i->root = dirname(str_replace("\\", "/", __FILE__));
// Where my $ani variable is accessible everywhere.
This way whenever I need to include/require files I can simply do something like include "{$ani->i->root}/modules/somemodule.php"
and not have to worry about paths, etc.