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?
Relative path problem
Moderator: General Moderators
Re: Relative path problem
Code: Select all
include dirname(__FILE__) . '/path/relative/to/the/including/file.php';
Re: Relative path problem
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.).
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.).