PHP get current page URL address and Parameters _php Tutorial

Source: Internet
Author: User
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 ...

  • 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.