You are here: Re: PHP 5 relative paths don't work?? « PHP Programming Language « IT news, forums, messages
Re: PHP 5 relative paths don't work??

Posted by Max on 07/28/06 14:50

Miguel Cruz wrote:
> "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).


__FILE__ seems to work ok for require and file, but for fopen it fails
no matter how I construct it.

Based on the work arounds listed above (which I appreciate), I guess
there is no way to get PHP 5 to work like PHP 4 in which it can figure
out the location of files relative to itself just by listing the file
name.

Would this be considered a bug?

Thanks,
Max

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация