note 120979 added to reserved.variables.server

From: Date: Wed, 12 Apr 2017 23:44:32 +0000
Subject: note 120979 added to reserved.variables.server
Groups: php.notes 
Request: Send a blank email to php-notes+get-209025@lists.php.net to get a copy of this message
Guide to URL paths... Data: $_SERVER['PHP_SELF'] Data type: String Purpose: The URL path name of the current PHP file, including path-info (see $_SERVER['PATH_INFO']) and excluding URL query string. Includes leading slash. Caveat: This is after URL rewrites (i.e. it's as seen by PHP, not necessarily the original call URL). Works on web mode: Yes Works on CLI mode: Tenuous (emulated to contain just the exact call path of the CLI script, with whatever exotic relative pathname you may call with, not made absolute and not normalised or pre-resolved) Data: $_SERVER['SCRIPT_NAME'] Data type: String Purpose: The URL path name of the current PHP file, excluding path-info and excluding URL query string. Includes leading slash. Caveat: This is after URL rewrites (i.e. it's as seen by PHP, not necessarily the original call URL). Caveat: Not set on all PHP environments, may need setting via preg_replace('#\.php/.*#', '.php', $_SERVER['PHP_SELF']). Works on web mode: Yes Works on CLI mode: Tenuous (emulated to contain just the exact call path of the CLI script, with whatever exotic relative pathname you may call with, not made absolute and not normalised or pre-resolved) Data: $_SERVER['REDIRECT_URL'] Data type: String Purpose: The URL path name of the current PHP file, path-info is N/A and excluding URL query string. Includes leading slash. Caveat: This is before URL rewrites (i.e. it's as per the original call URL). Caveat: Not set on all PHP environments, and definitely only ones with URL rewrites. Works on web mode: Yes Works on CLI mode: No Data: $_SERVER['REQUEST_URI'] Data type: String Purpose: The URL path name of the current PHP file, including path-info and including URL query string. Includes leading slash. Caveat: This is before URL rewrites (i.e. it's as per the original call URL). * *: I've seen at least one situation where this is not true (there was another $_SERVER variable to use instead supplied by the URL rewriter), but the author of the URL rewriter later fixed it so probably fair to dismiss this particular note. Caveat: Not set on all PHP environments, may need setting via $_SERVER['REDIRECT_URL'] . '?' . http_build_query($_GET) [if $_SERVER['REDIRECT_URL'] is set, and imperfect as we don't know what GET parameters were originally passed vs which were injected in the URL rewrite] --otherwise-- $_SERVER['PHP_SELF'] . '?' . http_build_query($_GET). Works on web mode: Yes Works on CLI mode: No Data: $_SERVER['PATH_INFO'] Data type: String Purpose: Find the path-info, which is data after the .php filename in the URL call. It's a strange concept. Caveat: Some environments may not support it, it is best avoided unless you have complete server control Works on web mode: Yes Works on CLI mode: No Note that if something is not set it may be missing from $_SERVER, or it may be blank, so use PHP's 'empty' function for your test. ---- Server IP: 72.52.91.14 Probable Submitter: 86.3.44.227 ---- Manual Page -- http://php.net/manual/en/reserved.variables.server.php Edit -- https://master.php.net/note/edit/120979 Del: integrated -- https://master.php.net/note/delete/120979/integrated Del: useless -- https://master.php.net/note/delete/120979/useless Del: bad code -- https://master.php.net/note/delete/120979/bad+code Del: spam -- https://master.php.net/note/delete/120979/spam Del: non-english -- https://master.php.net/note/delete/120979/non-english Del: in docs -- https://master.php.net/note/delete/120979/in+docs Del: other reasons-- https://master.php.net/note/delete/120979 Reject -- https://master.php.net/note/reject/120979 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#209025) next »