|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-02-06 21:44 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 22 00:00:01 2025 UTC |
Finding the name of the currently running script (to save it, for instance, before branching) requires too much messing around to make it operating system independent. This sort of complexity should be hidden from end-user programmers. An example of the hoops needed to be jumped through is shown below: function me() { /* returns the name of the current script, without the querystring portion. * this function is necessary because PHP_SELF and REQUEST_URI and PATH_INFO * return different things depending on a lot of things like your OS, Web * server, and the way PHP is compiled (ie. as a CGI, module, ISAPI, etc.) */ if (getenv("REQUEST_URI")) { $me = getenv("REQUEST_URI"); } elseif (getenv("PATH_INFO")) { $me = getenv("PATH_INFO"); } elseif (ini_get('register_globals') && $GLOBALS["PHP_SELF"]) { $me = $GLOBALS["PHP_SELF"]; // Supply default case that works when register_globals = Off - RJ } else $me = $_SERVER['SCRIPT_NAME']; return strip_querystring($me); } I think this can be improved. PHP_SELF is quoted as the standard solution, but I think you'll find those pushing it are relying on a particular O/S or server.