SERVER数组
$_SERVER数组属于超全局数组变量。$_SERVER数组包含了一系列由web服务器创建的数据,编程过程中,可以使用$_SERVER数组很轻易的获得和服务端相关的数据。$_SERVER数组包换了例如:头信息、服务器主机名、PHP的文件信息等等。
举个例子:我使用print_r()打印出我本地的服务端相关数据。
<?php
echo '<pre>';
print_r($_SERVER);
?>
它列出了我本地服务器上$_SERVER数组的内容。如下:
Array
(
[COMSPEC] => C:\WINDOWS\system32\cmd.exe
[DOCUMENT_ROOT] => e:/bae
[HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
[HTTP_ACCEPT_CHARSET] => GBK,utf-8;q=0.7,*;q=0.3
[HTTP_ACCEPT_ENCODING] => gzip,deflate,sdch
[HTTP_ACCEPT_LANGUAGE] => zh-CN,zh;q=0.8
[HTTP_CONNECTION] => keep-alive
[HTTP_COOKIE] => bdshare_firstime=1356335743658; CNZZDATA2262423=cnzz_eid=29272136-1359802178-&ntime=1359802178&cnzz_a=0&retime=1359802497789&sin=<ime=1359802497789&rtime=0; USR=cmtbinvi%0974%091361783123%09http%3A%2F%2Flocalhost%2Fshunde56%2F
[HTTP_HOST] => localhost
[HTTP_REFERER] => http://localhost/
[HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11
[PATH] => C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;F:\cpu37king\Subversion\bin;D:\Program Files\Subversion\bin;D:\Program Files\TortoiseSVN\bin;
[REDIRECT_STATUS] => 200
[REDIRECT_URL] => /edu/
[REMOTE_ADDR] => 127.0.0.1
[REMOTE_PORT] => 1719
[SCRIPT_FILENAME] => e:/bae/edu/index.php
[SERVER_ADDR] => 127.0.0.1
[SERVER_ADMIN] => [no address given]
[SERVER_NAME] => 127.0.0.1
[SERVER_PORT] => 80
[SERVER_SIGNATURE] =>
Apache/1.3.33 Server at 127.0.0.1 Port 80
[SERVER_SOFTWARE] => Apache/1.3.33 (Win32) PHP/5.1.2
[SystemRoot] => C:\WINDOWS
[WINDIR] => C:\WINDOWS
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_PROTOCOL] => HTTP/1.1
[REQUEST_METHOD] => GET
[QUERY_STRING] =>
[REQUEST_URI] => /edu/
[SCRIPT_NAME] => /edu/index.php
[PATH_TRANSLATED] => e:/bae/edu/index.php
[PHP_SELF] => /edu/index.php
[REQUEST_TIME] => 1361867733
)
0
0