常用知识 - $_SERVER 数组样本

  • 作者:KK

  • 发表日期:2020.03.16


有时候写一些代码需要用到 $_SERVER 数组,但你可能会忘记要取的键名拼写,或者不确定它是否存在某个值的 KEY,这里贴一个样本提供参考,方便快速确认,也可以复制键名去用:

Array
(
    [HTTP_HOST] => test.com
    [HTTP_CONNECTION] => keep-alive
    [HTTP_CACHE_CONTROL] => max-age=0
    [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.26 Safari/537.36 Core/1.63.5514.400 QQBrowser/10.1.1660.400
    [HTTP_UPGRADE_INSECURE_REQUESTS] => 1
    [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.9
    [PATH] => C:\Python27\;C:\Python27\Scripts;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\TortoiseGit\bin;C:\Program Files (x86)\WinSCP\;C:\Program Files\TortoiseSVN\bin;C:\Program Files\nodejs\;C:\ProgramData\ComposerSetup\bin;C:\Program Files\Microsoft VS Code\bin;C:\Users\admin\AppData\Local\VanDyke Software\Clients\;C:\Users\admin\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Docker Toolbox;C:\Program Files\Git\bin;D:\pg\phpStudy\PHPTutorial\php\php-7.2.1-nts;C:\Users\admin\AppData\Roaming\npm;C:\Users\admin\AppData\Local\Programs\Fiddler;C:\Users\admin\AppData\Roaming\Composer\vendor\bin
    [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] => 
    [SERVER_SOFTWARE] => Apache/2.4.23 (Win32) OpenSSL/1.0.2j PHP/5.4.45
    [SERVER_NAME] => test.com
    [SERVER_ADDR] => 127.0.0.1
    [SERVER_PORT] => 80
    [REMOTE_ADDR] => 127.0.0.1
    [DOCUMENT_ROOT] => D:/pj/test
    [REQUEST_SCHEME] => http
    [CONTEXT_PREFIX] => 
    [CONTEXT_DOCUMENT_ROOT] => D:/pj/test
    [SERVER_ADMIN] => admin@php.cn
    [SCRIPT_FILENAME] => D:/pj/test/t.php
    [REMOTE_PORT] => 57168
    [GATEWAY_INTERFACE] => CGI/1.1
    [SERVER_PROTOCOL] => HTTP/1.1
    [REQUEST_METHOD] => GET
    [QUERY_STRING] => 
    [REQUEST_URI] => /t.php
    [SCRIPT_NAME] => /t.php
    [PHP_SELF] => /t.php
    [REQUEST_TIME_FLOAT] => 1531450514.183
    [REQUEST_TIME] => 1531450514
)