Page 1 of 1

include a file from a file in a subdirectory

Posted: Tue Jan 29, 2008 11:28 am
by iacataca
Hi,

I have /a.php, /dir1/b.php, /dir1/c.php. a.php does include("dir1/b.php") and b.php does include("c.php"). Retrieving http://server/a.php shows that c.php cannot be found. I understand this is the normal behavior, from what I read from the include documentation.

My question is this: What do I have to change in php.ini or elsewhere to make this code work without changing the code or moving the files? Or maybe there is an extension/module that alters this behavior? I read the include documentation and I searched on a few forums but could not find an answer.

Thanks!

Re: include a file from a file in a subdirectory

Posted: Tue Jan 29, 2008 12:23 pm
by Christopher
It looks like your include_path setting in php.ini does not contain the '.' (current) directory.

Re: include a file from a file in a subdirectory

Posted: Tue Jan 29, 2008 3:29 pm
by iacataca
arborint wrote:It looks like your include_path setting in php.ini does not contain the '.' (current) directory.
It does include ".", but the current directory is "/".

Is there a way to automatically change the current directory when including a file which is in a different directory?

Or is there a way to alter the include behavior to check first the files in the same directory when the path is not absolute?