The main is to get to the address bar some information, domain names, port parameters, etc.
Copy CodeThe code is as follows:
Get domain name or host address
echo $_server[' Http_host ']. "
";
Get web Address
echo $_server[' php_self ']. "
";
Get URL parameters
echo $_server["Query_string"]. "
";
Detailed address of the source page
echo $_server[' Http_referer ']. "
";
?>
PHP gets the current script URL (only path)
Copy CodeThe code is as follows:
function Getcururl ()
{
if (!empty ($_server["Request_uri"))
{
$scrtName = $_server["Request_uri"];
$nowurl = $scrtName;
}
Else
{
$scrtName = $_server["Php_self"];
if (Empty ($_server["query_string"]))
{
$nowurl = $scrtName;
}
Else
{
$nowurl = $scrtName. "?". $_server["Query_string"];
}
}
return $nowurl;
}
Instance Invocation method
Echo Getcururl ();
PHP Get URL address does not include path (domain name or IP address)
Copy CodeThe code is as follows:
function getServerName ()
{
$ServerName = Strtolower ($_server[' server_name ']?$_server[' server_name ']:$_server[' http_host ']);
if (Strpos ($ServerName, '/http '))
{
Return Str_replace (' http://', ', $ServerName);
}
return $ServerName;
}
Instance Invocation method
Echo getServerName ();
PHP get URL address contains port path
Copy CodeThe code is as follows:
Echo ' http://'. $_server[' server_name ', '. '. $_server["Server_port"].$_server["Request_uri"];
http://www.bkjia.com/PHPjc/319866.html www.bkjia.com true http://www.bkjia.com/PHPjc/319866.html techarticle The main is to get to the address bar some information, domain names, port parameters, such as copy code code as follows:? PHP//Get the domain name or host address echo $_server[' http_host '. " BR "; Get Web site ...