PHP4 -> PHP5: require does not check file directory anymore?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

In my application I have lots of require statements that include files  
residing in the same directory:

index.php requires:

page.php requires:

Now I try to install the application on a PHP5 server (Apache), and this  
does not work anymore.

In the PHP4 -> PHP5 migration chapter of the manual I did not find any  
notes on a change of the require/include behaviour, not checking the  
directory of the calling file anymore; nor did I find it googling. So I  
am not sure if it is an undocumented migration issue or just a setting.

I understand that I can use:

But this means rewriting the whole application. Is there a way to change  
this behaviour via ini_set()? (As I am in a shared hosting environment I  
have no direct access to the php.ini.)

Thanks for hints

Re: PHP4 -> PHP5: require does not check file directory anymore?

Quoted text here. Click to load it

Maybe your PHP5 configuration file doesn't set same include_path option
than PHP4? You can add current directory (.) to include_path with this:

  set_include_path(get_include_path() . PATH_SEPARATOR . '.');

Jari Jokinen

Re: PHP4 -> PHP5: require does not check file directory anymore?

Jari Jokinen schrieb:
Quoted text here. Click to load it

Thank you, I tried this, but then it turned out to be something trivial:  
there was an open_basedir restriction on the PEAR include path.

Though there was no including of a PEAR file at all, PHP seems to check  
the include path directories and output an open_basedir error before  
checking the directory the file resides in.

I am not quite sure about where this behaviour is set - anyway if this  
is a new behaviour of PHP5 it should IMO be documented.


Site Timeline