Re: include_path and absolute paths in include functions

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

 



I am now needing to switch to absolute paths:
include_once ("/lib/included.php");

why do you need to do that? that include will bypass the include_path
and only look in the /lib dir on your machine - which is not what you want I think.

Thanks everyone for your great responses. What was my rationale for wanting to use a leading '/'?

A fair question. A flickering memory of a vague warning on some web page that using anything but absolute paths in include functions creates a security risk. Also, some unclear documentation in a certain, popular PHP/MySQL book (I won't name names) that I got started with a few years back.

My misunderstanding was that there is a concatenation taking place between include_path and the argument being passed to include(). I believe that I am now understanding correctly that the two options are:

a. Creating a relative path to the include, for instance:
include_once ("lib/included.php");

or

b. Putting the include into a directory listed in include_path, which basically has the same effect as using absolute paths - the effect being that if the file containing the include() call is moved to a different directory, the included file will still be found successfully, without having to keep the path relationship between the two files intact.

Further, I read (in the same PHP book) that it is best to refer to included files within the same directory like so:
include_once ("./included.php");

However, this would make the path relative, and would thus break if the file containing the include() call were to be moved, as I understand UNIX directory naming. Is there any benefit to doing this that would override my wish to be able to move files around with more freedom?

Finally, is there any greater security risk in using one or the other of relative versus 'include_path'-based paths? I know that putting a variable into the path is a no-no, but any other considerations?

Thanks again all!

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[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