1. $ _ ServerIs an array containing headers, paths, and script locations. The object of the array is created by the Web server. It is not guaranteed that all servers can generate all information.
<? PHP
Echo "http_user_agent:". $ _ server [Http_user_agent]. "<Br>"; // user_agent of the current request: Content in the header. Mozilla/4.0 (...
Echo "php_self:". $ _ server [Php_self]. "<Br>"; // file name path of the script being executed, relative to document root. /Test. php
Echo "SERVER_NAME:". $ _ server [SERVER_NAME]. "<Br>"; // host name, DNS alias, or IP address. Localhost
Echo "server_software:". $ _ server [Server_software]. "<Br>"; // string of the server ID. Apache/2.2.4 (win32 )...
Echo "QUERY_STRING:". $ _ server [QUERY_STRING]. "<Br>"; // query string. Haha = 33
Echo "document_root:". $ _ server [Document_root]. "<Br>"; // the root directory of the document where the script is currently running. C:/XAMPP/htdocs
Echo "http_host:". $ _ server [Http_host]. "<Br>"; // host of the current request: Content in the header. Localhost
Echo "remote_addr:". $ _ server [Remote_addr]. "<Br>"; // request the IP address of the machine on this page. 127.0.0.1
Echo "remote_host:". $ _ server [Remote_host]. "<Br>"; // request the host name of the machine on this page. If the machine does not have a DNS record, the variable is null.
Echo "http_referer:". $ _ server [Http_referer]. "<Br>"; // the browser comes to the previous page of the current page, which is empty
Echo "script_name:". $ _ server [Script_name]. "<Br>"; // path containing the current script. This is useful when the page needs to point to itself. Test/test. php
Echo "script_filename:". $ _ server [Script_filename]. "<Br>"; // the absolute path name of the currently executed script. C:/XAMPP/htdocs/test. php
?>
2. Differences between script_name and php_self
From: http://www.sonyfeel.com/doc.php? Action = view & docId = 9
on the current machine, the website $ _ server ['script _ name'] and $ _ server ['php _ Self '] are usually unavailable, because most PHP does not run in CGI Mode.
but dreamhost PHP runs in CGI mode, and the difference between the two is obvious.
echo $ _ server ['script _ name']; // (/cgi-system/PHP. CGI)
echo $ _ server ['php _ Self ']; // (/admin/test. PHP)