From:             [EMAIL PROTECTED]
Operating system: Win2K Server
PHP version:      4.2.3
PHP Bug Type:     Feature/Change Request
Bug description:  Function needed to return name of current script independent of O/S

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.

-- 
Edit bug report at http://bugs.php.net/?id=20902&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=20902&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=20902&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=20902&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=20902&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=20902&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=20902&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=20902&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=20902&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=20902&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=20902&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20902&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=20902&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=20902&r=isapi

Reply via email to