|
Posted by Miguel Cruz on 07/28/06 10:52
"Max" <max@kipness.com> wrote:
> Just switched to PHP 5 and just realized that all my scripts with
> relative paths for require statements no longer work unless I put the
> absolute path. Usually, if the file is in the same directory I would us
> the following statement:
>
> require 'file.php';
>
> Now I'm having to use:
>
> require '/var/www/html/file.php';
>
> Do I just need to convert everthing to absolute, or is there something
> I'm missing somewhere?
I have observed some flakiness in the way PHP5 is handling the current
working directory.
With PHP4 it always seems to be the directory that holds the current
script, as tested with the simple script:
<? system('pwd') ?>
With PHP5 I had observed a couple days ago that the value of PWD
actually changed during the course of script execution sometimes,
despite my not doing anything overt to cause that. This seemed to me
like a bug, but I didn't have time then to look into it further.
Trying now, with PHP5 on this machine, PWD always seems to be Apache's
value of DocumentRoot (no, not $ENV['PWD']). This breaks many scripts
that expect to be able to refer to data files relative to themselves.
If PWD cannot be trusted, then setting the include_path to include '.'
doesn't help (but the __FILE__ tricks will).
miguel
--
Photos from 40 countries on 5 continents: http://travel.u.nu
Latest photos: Malaysia; Thailand; Singapore; Spain; Morocco
Airports of the world: http://airport.u.nu
Navigation:
[Reply to this message]
|