Re: AW: [PHP] beginners question
| From: | Sachin Raut | Date: | Fri, 31 Oct 2014 06:19:35 +0000 |
| Subject: | Re: AW: [PHP] beginners question | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general php.general |
| Request: | Send a blank email to php-general+get-324020@lists.php.net to get a copy of this message | ||
Thanks Tobius, Jim & Andy. I didn't know anything about "include_path".
Thanks to all for discussing it in detail.
@Tobius
I did know about "../" (double dot) but had never seen "./" (single dot
followed by forward slash) before.
@Jim
Yes you are right......both statements does the same thing.
@Andy
Thanks for explaining in simple language.
And really sorry for getting back so late.
regards
Sachin
On Wed, Oct 15, 2014 at 8:53 PM, Andy McKenzie <amckenzie4@gmail.com> wrote:
> On Wed, Oct 15, 2014 at 10:04 AM, Tobias Fichtner <info@tobiasfichtner.com
> >
> 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
>