[thelist] PHP includes not recognizing root
Tim Fountain
tim at incutio.com
Sat Sep 6 18:39:55 CDT 2003
On Saturday, September 6, 2003 at 09:47, Ken wrote:
> I'm finding that when I use a PHP include, to get to the root
> directory, I have to use "../etc".
> Why won't it allow me to just use "/etc" to return to the root and
> what do I need to do to fix it?
As someone else said, / to PHP is the "real" server root directory,
not the URL root. It's usual to use the ENV variable DOCUMENT_ROOT for
this sort of thing, e.g.:
include($_SERVER['DOCUMENT_ROOT'].'/file/myfile.php');
Just make sure you check whether your DOCUMENT_ROOT has a trailing
slash or not (they don't usually).
--
Tim Fountain | Web developer | Incutio Limited | www.incutio.com
email: tim at incutio.com | Tel: +44 8708 700 333 | Fax: +44 7092 181 581
More information about the thelist
mailing list