1, $_server["script_name"]
Description: Contains the path of the current script
2, $_server["php_self"]
Description: The file name of the currently executing script
3, $_server["query_string"]
Description: A string that queries (query)
4, $_server["Request_uri"]
Description: The URI required to access this page
Instance:
1.http://blog.snsgou.com/ (Open homepage directly)
Results:
$_server["script_name"] = "/index.php" $_server["php_self"] = "/index.php" $_server["query_string"] = "" $_SERVER[ "Request_uri"] = "/"
2.http://blog.snsgou.com/?p=222 (with Enquiry)
Results:
$_server["script_name"] = "/index.php" $_server["php_self"] = "/index.php" $_server["query_string"] = "p=222" $_ server["Request_uri"] = "/?p=222"
3.http://blog.snsgou.com/index.php?p=222&q=biuuu
Results:
$_server["script_name"] = "/index.php" $_server["php_self"] = "/index.php" $_server["query_string"] = "p=222& Q=biuuu "$_server[" request_uri "] ="/index.php?p=222&q=biuuu "
4.http://blog.snsgou.com/123/123.php/abc/def?id=222&name=jack
$_server["script_name"] = "/123/123.php" $_server["php_self"] = "/123/123.php/abc/def" $_server["QUERY_STRING"] = "Id=222&name=jack" $_server["request_uri"] = "/123/123.php/abc/def?id=222&name=jack"
5.http://blog.snsgou.com/123/123.php/abc/def.bat?id=222&name=jack
$_server["script_name"] = "/123/123.php" $_server["php_self"] = "/123/123.php/abc/def.bat" $_server["QUERY_ STRING "] =" Id=222&name=jack "$_server[" request_uri "] ="/123/123.php/abc/def.bat?id=222&name=jack "
- $_server["Script_name"] gets the path to the current script, such as: index.php
- $_server["Php_self"] the file name of the script that is currently executing
- $_server["Query_string"] gets the query statement, in the instance, gets the following value
- $_server["Request_uri"] gets the value after http://blog.snsgou.com, including/
To summarize, for Script_name, Php_self, Query_string, Request_uri, deep understanding will help us to correctly invoke these four values in the $_server function.
in general: $_server["Request_uri"] = $_server["Php_self"]. ‘?‘ . $_server["Query_string"]
Note: When there is an address rewrite , the situation changes somewhat, such as:
/class Rewrite to/index.php?app=class&mod=index&act=index
At this time
$_server[' php_self '] value equals /index.php
$_server[' query_string '] value equals /index.php?app=class&mod=index&act=index
$_server["Request_uri"] value equals /class
Uchome processing techniques in the system:
Processing Request_uriif (!isset ($_server[' Request_uri ')) {$_server[' Request_uri '] = $_server[' php_self ']; if (Isset ($_server[' query_string ')) $_server[' Request_uri ']. = '? '. $_server[' query_string ');} if ($_server[' Request_uri ') { $temp = UrlDecode ($_server[' Request_uri ']); if (strexists ($temp, ' < ') | | strexists ($temp, ' "')) { $_get = Shtmlspecialchars ($_get); XSS }}
Extended reading:
PHP gets the URL of the current page
PHP Gets the difference between the current domain name $_server[' http_host '] and $_server[' server_name ']
An XSS vulnerability attack caused by PHP's $_server[' php_self ' and its solutions
$_server["Script_name"], $_server["php_self"], $_server["query_string"], $_server["Request_uri"]