**一、$_SERVER['HTTP_HOST']**
*****
~~~
var_dump($base_url);
var_dump($_SERVER['PHP_SELF']);
var_dump($_SERVER['REQUEST_URI']);
var_dump('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']);
~~~
以上代码的输出结果
~~~
string 'http://192.168.1.66/test/list.php?m=category' (length=44)
string '/test/list.php' (length=14)
string '/test/list.php?m=category&p=10' (length=30)
string 'http://192.168.1.66/test/list.php?m=category&p=10' (length=49)
~~~
~~~
var_dump($_SERVER);
~~~
以上代码在windows下输出结果
~~~
array (size=35)
'HTTP_HOST' => string '192.168.1.66' (length=12)
'HTTP_CONNECTION' => string 'keep-alive' (length=10)
'HTTP_ACCEPT' => string 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' (length=74)
'HTTP_UPGRADE_INSECURE_REQUESTS' => string '1' (length=1)
'HTTP_USER_AGENT' => string 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2652.2 Safari/537.36' (length=112)
'HTTP_ACCEPT_ENCODING' => string 'gzip, deflate, sdch' (length=19)
'HTTP_ACCEPT_LANGUAGE' => string 'zh-CN,zh;q=0.8' (length=14)
'HTTP_COOKIE' => string '_ga=GA1.1.86506785.1460774855; CNZZDATA155540=cnzz_eid%3D895721492-1460974636-http%253A%252F%252F192.168.1.66%252F%26ntime%3D1460974636; __utma=57025002.86506785.1460774855.1460964953.1460975251.4; __utmz=57025002.1460774855.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); PHPSESSID=ano1i27118fgpl5jajivkippc5' (length=312)
'PATH' => string 'C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;' (length=100)
'SystemRoot' => string 'C:\WINDOWS' (length=10)
'COMSPEC' => string 'C:\WINDOWS\system32\cmd.exe' (length=27)
'PATHEXT' => string '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC' (length=53)
'WINDIR' => string 'C:\WINDOWS' (length=10)
'SERVER_SIGNATURE' => string '<address>Apache/2.4.9 (Win64) PHP/5.5.12 Server at 192.168.1.66 Port 80</address>
' (length=82)
'SERVER_SOFTWARE' => string 'Apache/2.4.9 (Win64) PHP/5.5.12' (length=31)
'SERVER_NAME' => string '192.168.1.66' (length=12)
'SERVER_ADDR' => string '192.168.1.66' (length=12)
'SERVER_PORT' => string '80' (length=2)
'REMOTE_ADDR' => string '192.168.1.66' (length=12)
'DOCUMENT_ROOT' => string 'D:/www/www.14.com' (length=17)
'REQUEST_SCHEME' => string 'http' (length=4)
'CONTEXT_PREFIX' => string '' (length=0)
'CONTEXT_DOCUMENT_ROOT' => string 'D:/www/www.14.com' (length=17)
'SERVER_ADMIN' => string 'admin@example.com' (length=17)
'SCRIPT_FILENAME' => string 'D:/www/www.14.com/test/list.php' (length=31)
'REMOTE_PORT' => string '52351' (length=5)
'GATEWAY_INTERFACE' => string 'CGI/1.1' (length=7)
'SERVER_PROTOCOL' => string 'HTTP/1.1' (length=8)
'REQUEST_METHOD' => string 'GET' (length=3)
'QUERY_STRING' => string 'm=category&p=10' (length=15)
'REQUEST_URI' => string '/test/list.php?m=category&p=10' (length=30)
'SCRIPT_NAME' => string '/test/list.php' (length=14)
'PHP_SELF' => string '/test/list.php' (length=14)
'REQUEST_TIME_FLOAT' => float 1461030466.933
'REQUEST_TIME' => int 1461030466
~~~