Re: AW: beginners question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 15, 2014 at 10:04 AM, Tobias Fichtner <info@xxxxxxxxxxxxxxxxxx>
wrote:

> Hi,
>
> the point is that both include the same files if the include path contains
> "./" already.
>
>
>
Except that they don't.  They include one of the same files, but there's no
guarantee that it will be the one called.

Say I use "includes/config.inc.php".  Suppose that my include_path is set
to "/usr/php/54/usr/lib64:usr/php/54/usr/share/pear:.".  In this case,
there are three files that could be called.   The system first looks for
/usr/php/54/usr/lib64/includes/config.inc.php.  Then it looks for
usr/php/54/usr/share/pear/includes/config.inc.php.  Then it looks for
./includes/config.inc.php.  There are three possible files that can be
included there.  If there's a file in the first location, that's the one
that will be included.  Now, you can avoid that by making "." be the first
entry in the list (and, in fact, it is on my system), but unless you know
what the include path is you cannot guarantee what file will be called.

Now suppose I use "./includes/config.inc.php", and I'm calling it from
"/var/www/htdocs/myproject".  There is only one possible file that can be
called.

Is this nitpicking?  Yes, a bit.  However, I've been in a situation where
it mattered.  It was an early IT job, and I didn't really know what I was
doing, and neither did the other person working on the web server.  They
wrote a new program, and needed to add something to the include_path.
Rather than do it in their program, they went in and edited php.ini, adding
their directory as the first entry in the list.  Since we both had called
files called "config.inc", my program stopped working.

My point isn't so much that either way is wrong, as that if you don't
understand the behavior it can mess things up, and you won't understand why.

Andy

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux