Page 1 of 1
Relative path problem
Posted: Tue Jun 03, 2008 4:23 pm
by jjl
If I include a file from another page and the included file references another file, the path to that file is relative to the page that called the include not the included file.
Is there any way I can make the file paths relative to the include page?
Re: Relative path problem
Posted: Tue Jun 03, 2008 4:35 pm
by Weirdan
Code: Select all
include dirname(__FILE__) . '/path/relative/to/the/including/file.php';
I believe this save a couple of lstats as well - thus a bit faster.
Re: Relative path problem
Posted: Fri Jun 06, 2008 8:10 am
by jjl
Thanks, but then when I call it from another directory it will fail from that one because it will be relative to the other file that called it not the current one. The file will be called from many different directories, the problem is because using a call like include or require for some reason behave by assuming the called file is in the same as the calling file.
I am new at this but I cannot see a reason why the call cannot be to the exact file position rather that to a relative file position which is going to vary. Why do people dislike exact file poisitions like includ (http:/www/hereitis.com/now/you/have/FoundTheFile.ok.).