Re: AW: beginners question

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

 



On Wed, Oct 15, 2014 at 8:43 AM, Jim Giner <jim.giner@xxxxxxxxxxxxxxxxxx>
wrote:

> What tobias said I disagree with.  In both of your examples you have
> included a path.  The second one though adds that dot which I do believe
> means to start at the current directory.  I've never seen anyone use that
> syntax since your first one will do the same thing.
>
> If I'm wrong I'm sure we'll hear about this.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Tobias was more right, I think.

To break down the two constructions:

require 'includes/config.inc.php'; says "Look at the include path that PHP
knows about, and try to find a sub-directory called 'includes' that has a
file called 'config.inc.php'.  If you can't find it there, try the
directory you're running in."


require './includes/config.inc.php'; says "Look at the directory you're
running in, and then the sub-directory 'includes' and the file
'config.inc.php'.


So the two constructions don't actually do the same thing;  if there's a
file called 'includes/config.inc.php' anywhere in the global includes_path,
it will be called with the first setup.  That's one reason I almost always
use a fully defined path, like the second construction.  It makes it easier
to know exactly what file I'm going to be inserting into my code, and
reduces the risk of someone else on the system inserting their own code,
either accidentally or not.

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