[PHP Learning Tutorial-Network]003. Get the page URL for the current visit (present Request URL)

Source: Internet
Author: User

Introduction: Gets the URL path of the current request and automatically determines the protocol (HTTP or HTTPS).

A word of the matter, below directly on the HD without MSK of the subtle code!

function function

Gets the page path (URL) address of the current request

Syntax:$url = getpageurl()

return Result:

  string-Request URL

/** * get the current page address * * @author DO.ORG.CN#AC*/functionGetpageurl () {$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;}

Description: Support for the request protocol, only HTTP and HTTPS support, if more complex identification is required, you can add it yourself .


Combined with previous lecture <[php Learning Tutorial-Network]002.$_server["Script_name", $_server["Php_self"], $_server["query_string"], $_server[" Request_uri "] Introduction ($_server URL infomation) > To learn together, the effect is better.

Not finished, waiting to be updated ...

This site article is for baby bus SD. Team Original, reproduced must be clearly noted: (the author's official website: Baby bus )
Reprinted from "Baby bus Superdo Team" original link: http://www.cnblogs.com/superdo/p/4822702.html

[PHP Learning Tutorial-Network]003. Get the page URL for the current visit (present Request URL)

Related Article

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.