PHP tutorials get full URL address bar parameters in a variety of ways:
$_server["Server_port"]//get port
$_server[' Http_host ']//get the domain name or host address
$_server[' server_name ']//what does it mean to get a domain name or a host site php://input? PHP input Stream input address Note: Just the primary domain name such as xhxu.cn
$_server["Request_uri"]//get the domain name after the detailed address such as:/index.php?id=123 ...
$_server[' php_self ']//get PHP file name
$_server["query_string"]//get php URL parameters
$_server[' Http_referer ']//the detailed address of the source page
Output:
echo "rewrite:". $_get["Rewrite"];
echo "<br>server_port:". $_server["Server_port"];
echo "<br>http_host:". $_server["Http_host"];
echo "<br>server_name:". $_server["SERVER_NAME"];
echo "<br>request_uri:". $_server["Request_uri"];
echo "<br>php_self:". $_server["Php_self"];
echo "<br>query_string:". $_server["Query_string"];
echo "<br>http_referer:". $_server["Http_referer"];
Attention:
The difference between server_name and http_host in PHP
Enter the following URL in the address bar:
1) when
The corresponding values are:
HTTP_HOST:www.xhxu.cn
SERVER_NAME:xhxu.cn
2)
The corresponding values are:
HTTP_HOST:blog.xhxu.cn
SERVER_NAME:xhxu.cn
PHP $_server Property Description
- $_server[' php_self ') #当前正在执行脚本的文件名, related to document root.
- $_server[' argv '] #传递给该脚本的参数.
- $_server[' argc '] #包含传递给程序的命令行参数的个数 (if run in command-line mode).
- $_server[' gateway_interface ') #服务器使用的 the version of the CGI specification. For example, "cgi/1.1".
- $_server[' server_name '] #当前运行脚本所在服务器主机的名称.
- $_server[' Server_software '] #服务器标识的字串, given in the header in response to the request.
- $_server[' Server_protocol '] #请求页面时通信协议的名称和版本. For example, "http/1.0".
- $_server[' Request_method '] #访问页面时的请求方法. For example:, POST, PUT.
- A string of $_server[' query_string '] #查询 (QUERY).
- $_server[' Document_root '] #当前运行脚本所在的文档根目录. Defined in the server configuration file.
- $_server[' http_accept '#当前请求的 ACCEPT: The contents of the head.
- $_server[' Http_accept_charset '] #当前请求的 Accept-charset: The contents of the head. For example: "iso-8859-1, *,utf-8".
- $_server[' http_accept_encoding '] #当前请求的 accept-encoding: The contents of the head. For example: "gzip".
- $_server[' http_accept_language ']# the accept-language of the current request: the contents of the header. For example: "en".
- $_server[' http_connection '] #当前请求的 CONNECTION: The contents of the head. For example: "Keep-alive".
- $_server[' http_host '] #当前请求的 HOST: The contents of the head.
- $_server[' Http_referer '] #链接到当前页面的前一页面的 URL address.
- $_server[' http_user_agent '] #当前请求的 user_agent: The contents of the head.
- $_server[' https '-if accessed over HTTPS, it is set to a non-null value (on), otherwise it returns off
- $_server[' remote_addr '] #正在浏览当前页面用户的 IP address.
- $_server[' Remote_host '] #正在浏览当前页面用户的主机名.
- $_server[' Remote_port '] #用户连接到服务器时所使用的端口.
- $_server[' Script_filename '] #当前执行脚本的绝对路径名.
- $_server[' server_admin '] #管理员信息
- $_server[' Server_port '] #服务器所使用的端口
- $_server[' server_signature '] #包含服务器版本和虚拟主机名的字符串.
- $_server[' path_translated '#当前脚本所在文件系统 Basic path (not the document root).
- $_server[' Script_name '] #包含当前脚本的路径. This is useful when the page needs to point to itself.
- $_server[' Request_uri '] #访问此页面所需的 URI. For example, "/index.html".
- $_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 feature, which is the password that the user entered.
- $_server[' Auth_type '] #当 PHP runs in the Apache module mode and is using the HTTP authentication feature, which is the type of authentication.