include a file from a file in a subdirectory

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
iacataca
Forum Newbie
Posts: 5
Joined: Tue Jan 29, 2008 11:11 am

include a file from a file in a subdirectory

Post 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!
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: include a file from a file in a subdirectory

Post by Christopher »

It looks like your include_path setting in php.ini does not contain the '.' (current) directory.
(#10850)
iacataca
Forum Newbie
Posts: 5
Joined: Tue Jan 29, 2008 11:11 am

Re: include a file from a file in a subdirectory

Post 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?
Post Reply