Re: Getting The Document Root

From: Date: Thu, 02 Feb 2006 16:16:27 +0000
Subject: Re: Getting The Document Root
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-229738@lists.php.net to get a copy of this message
Jeremy Privett wrote:
John Nichel wrote:
$_SERVER['DOCUMENT_ROOT'] http://www.php.net/manual/en/reserved.variables.php#reserved.variables.server
Nope. I've already tried that... $_SERVER['DOCUMENT_ROOT'] contains /home/jeremy/public_html/test/ ... All I want is to the public_html part.
'DOCUMET_ROOT' will return what the web server's document root is, no matter what directory on that web server the script is run. ie, I'm running apache, look here.... http://www.nichel.net/docroot.php http://www.nichel.net/test/docroot.php http://www.nichel.net/bob/docroot.php http://www.nichel.net/bob/fred/docroot.php All four of those 'docroot.php' scripts are the same: <?php echo ( $_SERVER['DOCUMENT_ROOT'] ); ?> But they're in four different directories. Document root is just that, it's the directory where Apache (or other web servers) start serving files from for the particular domain. Either you're webserver is seriously hosed (I can't even imagine how), or document root is not what you're thinking it is. If you place a script three levels below the 'test' directory which echo's out document root, what's the output? -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 jnichel@dotcomholdingsofbuffalo.com

« previous php.general (#229738) next »