On Mon, May 22, 2006 12:12 am, Dave M G wrote: > What I am trying to achieve is to output the path in which the current > script is executing, without having the name of the file attached. I'm > hoping to be able to do this without complicated code to truncate path > names and whatnot. > > Either of these two variables do what I want, except that they include > the name of the file: > > $_SERVER[PHP_SELF] > $_SERVER[SCRIPT_NAME] > > For example, if create file called "test.php" and I echo the output of > $_SERVER[PHP_SELF], I get: > /web_sites/gutteridge.info/web/test.php > > But all I want is: > /web_sites/gutteridge.info/web > > (It's important that the last forward slash not be there). > > I would have thought that an existing global variable would exist to > do > this, but I can't find it in the php manual: > http://www.php.net/manual/en/reserved.variables.php > > $_SERVER[DOCUMENT_ROOT] provides a path without the file name, but > it's > not the path I need. In my case, the output is: > /var/www > > $_SERVER[PATH_TRANSLATED] also provides a different path, and also > attaches the file name: > /var/www/web_sites/gutteridge.info/web/test.php > > The bottom line is, how can I get the same path as $_SERVER[PHP_SELF] > or > $_SERVER[SCRIPT_NAME], but without including the file name? > > Thank you for any advice. http://php.net/dirname -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php