php $_SERVER 中的 QUERY_STRING和REQUEST_URI

index.php

<?php
print_r($_GET);
parse_str($_SERVER['QUERY_STRING'],$get);
print_r($get);
print_r($_SERVER);
?>

输出:

Array
(
    [a_a] => 1
    [b] => 2
)
Array
(
    [a_a] => 1
    [b] => 2
)
Array
(
    [HTTP_HOST] => www.my.com
    [HTTP_CONNECTION] => keep-alive
    [HTTP_UPGRADE_INSECURE_REQUESTS] => 1
    [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36
    [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
    [HTTP_ACCEPT_ENCODING] => gzip, deflate
    [HTTP_ACCEPT_LANGUAGE] => zh-CN,zh;q=0.8
    [PATH] => C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Java\jdk1.8.0_131\bin;D:\python2.7;C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps
    [SystemRoot] => C:\Windows
    [COMSPEC] => C:\Windows\system32\cmd.exe
    [PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
    [WINDIR] => C:\Windows
    [SERVER_SIGNATURE] => <address>Apache/2.4.23 (Win64) PHP/5.6.25 Server at www.my.com Port 80</address>

    [SERVER_SOFTWARE] => Apache/2.4.23 (Win64) PHP/5.6.25
    [SERVER_NAME] => www.my.com
    [SERVER_ADDR] => 127.0.0.1
    [SERVER_PORT] => 80
    [REMOTE_ADDR] => 127.0.0.1
    [DOCUMENT_ROOT] => D:/wamp64/www/my
    [REQUEST_SCHEME] => http
    [CONTEXT_PREFIX] => 
    [CONTEXT_DOCUMENT_ROOT] => D:/wamp64/www/my
    [SERVER_ADMIN] => wampserver@wampserver.invalid
    [SCRIPT_FILENAME] => D:/wamp64/www/my/index.php
    [REMOTE_PORT] => 49956
    [GATEWAY_INTERFACE] => CGI/1.1
    [SERVER_PROTOCOL] => HTTP/1.1
    [REQUEST_METHOD] => GET
    [QUERY_STRING] => a.a=1&b=2
    [REQUEST_URI] => /index.php?a.a=1&b=2
    [SCRIPT_NAME] => /index.php
    [PHP_SELF] => /index.php
    [REQUEST_TIME_FLOAT] => 1500294863.765
    [REQUEST_TIME] => 1500294863
)

变量名中的点和空格被转换成下划线。例如 <input name="a.b" /> 变成了 $_REQUEST["a_b"]

$_GET 和 $_REQUEST 已经被解码,query_string和request_uri没有解码,显示原始字符串。

posted @ 2017-07-17 20:38  S3c0ldW4ng  阅读(2528)  评论(0编辑  收藏  举报