Variable for returning the script's path w/out script name
Posted: Wed Feb 09, 2005 1:47 pm
I need a way to return the path of the current script, as opposed to the script name. Is there a $_SERVER or other variable for doing this? I need to do some IF-ELSE statements based on the path of a set of scripts, not the script names themselves.
For example, if I'm running a script at /home/user/www/domain.com/addresses/addresses.php, I need some sort of variable that returns the following:
/home/user/www/domain.com/addresses
Any ideas are appreciated.
For example, if I'm running a script at /home/user/www/domain.com/addresses/addresses.php, I need some sort of variable that returns the following:
/home/user/www/domain.com/addresses
Code: Select all
$_SERVERї'PHP_SELF']; //This returns the script name, not the root dir of the script
$_SERVERї'DOCUMENT_ROOT']; //this returns the root of the domain, not the root of the current script
$_SERVERї'SCRIPT_NAME']; //This returns the script name
$_SERVERї'PATH_TRANSLATED']; //This returns the full server path, including the script