My usual $_server[] variable
$_server[' http_accept_language ']//browser language
$_server[' REMOTE_ADDR '//Current user IP.
$_server[' remote_host '//Current user host name
$_server[' Request_uri ']//url
$_server[' Remote_port ']//port.
$_server[' server_name ']/the name of the server host.
$_server[' php_self ']//the filename of the script being executed
$_server[' argv '////parameters passed to the script.
$_server[' argc '////Number of command line arguments passed to the program.
$_server[' Gateway_interface ']//cgi the version of the specification.
$_server[' Server_software ']/server identity string
$_server[' server_protocol '////The name and version of the communication protocol when requesting the page
$_server[' Request_method ']//request method when accessing the page
string of $_server[' query_string '//Queries (query).
$_server[' document_root '///the document root directory where the current script is running
$_server[' http_accept '///current requested ACCEPT: header content.
$_server[' http_accept_charset '///current requested Accept-charset: header content.
$_server[' http_accept_encoding '///current requested accept-encoding: header content
$_server[' http_connection '///current requested CONNECTION: header content. For example: "Keep-alive".
$_server[' http_host '///Current requested HOST: The contents of the header.
$_server[' http_referer '///link to the URL address of the previous page of the current page.
$_server[' http_user_agent '///current requested user_agent: header content.
$_server[' https ']//if accessed through HTTPS, is set to a Non-empty value (on), otherwise it is returned off
$_server[' Script_filename '] #当前执行脚本的绝对路径名.
$_server[' Server_admin '] #管理员信息
$_server[' Server_port '] #服务器所使用的端口
$_server[' Server_signature '] #包含服务器版本和虚拟主机名的字符串.
$_server[' path_translated '] #当前脚本所在文件系统 (not the document root directory) the basic path.
$_server[' Script_name '] #包含当前脚本的路径. This is useful when the page needs to point to itself.
$_server[' Php_auth_user '] #当 PHP runs in the Apache module mode and is using the HTTP authentication feature, which is the user name entered by the user.
$_server[' PHP_AUTH_PW '] #当 PHP runs in the Apache module mode and is using the HTTP authentication function, which is the user input password.
$_server[' Auth_type '] #当 PHP runs in the Apache module mode and is using the HTTP authentication feature, which is the type of authentication
Page Program Related
$_server[' php_self ': The path to the root directory of the Web site and the name of the PHP program are related to document root.
$_server[' http_referer ': Link to the URL address of the previous page of the current page.
$_server[' script_name ': The path to the site root directory and the PHP program file name.
$_server[' Request_uri ': the URI required to access this page.
$_server[' script_filename ': the absolute path and filename of the currently running PHP program.
$_server[' path_translated ': the base path for the current PHP program's file system (not the document root).
$_server[' query_string ': A string of Queries (query) (the first question mark in the URL)? After the content but not the # after the content).
$_server[' argv ': parameters passed to the current PHP program.
$_server[' argc ': in command line mode, contains the number of command-line arguments passed to the program.
$_server[' request_time ': Timestamp at the start of the request, valid from PHP 5.1.0.
$_server[' Request_method ': The request method when accessing the page, for example:, POST or put.
$_server[' http_accept ': The contents of the current requested ACCEPT: header information.
$_server[' http_accept_charset ': The contents of the current requested Accept-charset: header information. For example: "Iso-8859-1,*,utf-8".
$_server[' http_accept_encoding ': The contents of the current requested accept-encoding: header information. For example: "gzip".
$_server[' http_accept_language ': The contents of the current requested accept-language: header information. For example: "ZH-CN".
$_server[' http_connection ': The contents of the current requested CONNECTION: header information. For example: "Keep-alive".
$_server[' http_host ': The contents of the current requested HOST: header information.
$_server[' https ': If the PHP program is accessed through the HTTPS protocol, it is set to a Non-empty value.
$_server[' php_auth_digest ': When running as an Apache module, this variable is set to the "Authorization" HTTP sent by the client during the HTTP DIGEST authentication process. Header content (for further authentication operations).
$_server[' php_auth_user ': When PHP is running in Apache or IIS (PHP 5 is ISAPI) module mode, and is using the HTTP authentication function, this variable is the user entered user name.
$_server[' php_auth_pw ': When PHP is running in the Apache or IIS (PHP 5 is ISAPI) module mode, and is using the HTTP authentication function, this variable is the user entered the password.
$_server[' auth_type ': When PHP is running in the Apache module mode, and is using the HTTP authentication function, this variable is the type of authentication.
Server-Side related
$_server[' document_root ': The document root directory where the PHP program is currently running, defined in the server configuration file.
$_server[' gateway_interface ': The version of the CGI specification used by the server, for example: "cgi/1.1".
$_server[' server_addr ': The IP address of the server where the PHP program is currently running.
$_server[' server_name ': The name of the server where the PHP program is currently running.
$_server[' server_admin ']:apache the server_admin parameters in the server configuration file.
$_server[' server_port ': The port used by the server. If you are using SSL secure connections, this value is the HTTP port that the user sets.
$_server[' server_signature ': A string containing the server version and the virtual host name.
$_server[' server_software ': A string of server identities, given in the header information in response to the request.
$_server[' Server_protocol ': The name and version of the communication protocol when the page is requested, for example: "http/1.0".
Other miscellaneous
$_server[' http_user_agent ': The contents of the current requested user-agent: header information that indicates the user agent that accessed the page.
$_server[' remote_addr ': The IP address of the user who is browsing the current page.
$_server[' remote_host ': The host name of the user who is browsing the current page.
$_server[' remote_port ': The port used by the user to connect to the server.
Note that if you run PHP on the command line, the elements listed above are almost not valid (or have no real meaning).
Example 1
PHP gets the current URL path
1,$_server["Query_string"]
Description: String for query
2,$_server["Request_uri"]
Description: The URI required to access this page
3,$_server["Script_name"]
Description: The path containing the current script
4,$_server["Php_self"]
Description: The filename of the current script being executed
Instance:
1,http://www.111cn.net/(open homepage directly)
Results:
$_server["query_string"] = ""
$_server["Request_uri"] = "/"
$_server["script_name"] = "/index.php"
$_server["php_self"] = "/index.php"
2,http://www.111cn.net/?p=222 (incidental query)
Results:
$_server["query_string"] = "p=222"
$_server["Request_uri"] = "/?p=222"
$_server["script_name"] = "/index.php"
$_server["php_self"] = "/index.php"
3,http://www.111cn.net/index.php?p=222&q=biuuu
Results:
$_server["query_string"] = "p=222&q=biuuu"
$_server["Request_uri"] = "/index.php?p=222&q=biuuu"
$_server["script_name"] = "/index.php"
$_server["php_self"] = "/index.php"
$_server["Query_string"] gets the query statement, which, in the instance, gets the value of the following?
$_server["Request_uri"] gets the value that follows the http://www.111cn.net, including/
$_server["Script_name"] gets the path to the current script, such as: index.php
$_server["Php_self"] The file name that is currently executing the script
Current URL: "http://". $_server[' http_host '].$_server[' php_self '
To summarize, for Query_string,request_uri,script_name and php_self, deep understanding will help us to call these four values correctly in the $_server function. The difference between the four variables is query_string,request_uri,script_name and php_self in the $_server function by an example.