PHP's predefined variable, $_server, is an array of headers (headers), path information, and the location of the script, and the entity of the array is created by the Web server.
Using the $_server array, we can get the URL full path and the real path, let oneself use them arbitrarily.
$_server[' server_name '///The name of the server host where the script is currently running.
$_server[server_port ')//The port used by the user when connecting to the server.
$_server[' Request_uri '///currently running the script except for the host name of the request URL.
$_server[' document_root '///the document root directory where the script is currently running.
Example url:http://www.cndong.cn/test/test.php
$_server[' server_name ': www.cndong.cn
$_server[' Server_port ': 80www.2cto.com
$_server[' Request_uri ':/test/test.php
$_server[' document_root ':/home/var/www/cndong.cn/htdocs
So the URL full path is "http://". $_server[' server_name '].$_server[' Request_uri ']
Description
1. The default HTTP port is 80, so General $_server[' Server_port '] does not include URL full path, of course special case, special treatment!
2. Someone will use $_server[' remote_host ' to get the hostname, but it means: Browsing the host name of the current page user (this variable must be created by the Web server).
Extended:
$_server[' Remote_host ' is a workaround for null values
Modify hostnamelookups in Apache server configuration file httpd.conf to On
Author: Xu Xiujun
http://www.bkjia.com/PHPjc/478162.html www.bkjia.com true http://www.bkjia.com/PHPjc/478162.html techarticle PHP's predefined variable, $_server, is an array of headers (headers), path information, and the location of the script, and the entity of the array is created by the Web server. Using the $_server array, we can get the URL end ...