PHP get Address bar URL function _php Tutorial

Source: Internet
Author: User
Get a URL address in PHP I will use the Super global variable $_server, he includes a variety of parameters, such as Http_host, php_self, query_string, etc., here is not introduced.

PHP gets the URL of a few functions introduced

The code is as follows Copy Code

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 ']. "
";
?>

Combine the above several functions to get the full URL address

The code is as follows Copy Code

Description: Get the full URL

function Curpageurl ()
{
$pageURL = ' http ';

if ($_server["HTTPS"] = = "on")
{
$pageURL. = "S";
}
$pageURL. = "://";

if ($_server["Server_port"]! = "80")
{
$pageURL. = $_server["SERVER_NAME"]. ":" . $_server["Server_port"]. $_server["Request_uri"];
}
Else
{
$pageURL. = $_server["SERVER_NAME"]. $_server["Request_uri"];
}
return $pageURL;
}
?>

Once you have defined the function, you can call it directly:

The code is as follows Copy Code

Echo Curpageurl ();
?>

http://www.bkjia.com/PHPjc/633120.html www.bkjia.com true http://www.bkjia.com/PHPjc/633120.html techarticle get a URL address in PHP I will use the Super global variable $_server, he includes a variety of parameters, such as Http_host, php_self, query_string, etc., here is not introduced. PHP get ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.