PHP gets the current page URL address and parameters to get the full address of the current page we have to go through a lot of operations such as HTTP or https PHP files and path host domain name query parameters finally become. Get protocol-HTTP
PHP tutorial get current page URL address and parameters
To get the full address of the current page we have to go through a lot of operations such as HTTP or HTTPS tutorial PHP files and path host domain name query parameters are finally made.
Get protocol-HTTP
The URL of the protocol can be read out in the $ _SERVER [' server_protocol '] variable.
*/
echo $_server[' Server_protocol '];
/*
If you check the value, you can find that it is not just http or HTTPS, but such a string: http/1.1 's
*/
$protocol = Strpos (Strtolower ($_server[' server_protocol '), ' https ') = = = = False? ' http ': ' HTTPS ';
/*
Get host Domain name */
$host = $_server[' http_host ');
/*
Use $ _server[' script_name '] to get PHP files and paths in addition to the domain name
*/
$script = $_server[' script_name ');
Get back query parameters
$params = $_server[' query_string ');
Method Two
$uri = $_server[' Request_uri ');
Let's look at a complete get current URL instance
$protocol = Strpos (Strtolower ($_server[' server_protocol '), ' https ') = = = = False? ' http ': ' HTTPS ';
$host = $_server[' http_host ');
$script = $_server[' script_name ');
$params = $_server[' query_string ');
$currenturl = $protocol. '://' . $host. $script. '?' . $params;
Echo $currenturl;
http://www.bkjia.com/PHPjc/631733.html www.bkjia.com true http://www.bkjia.com/PHPjc/631733.html techarticle PHP Gets the current page URL address and parameters to get the full address of the current page we have to go through a lot of operations such as HTTP or https PHP files and path host domain name query parameters finally become. be ...