ph get current URL path and server path summary (URL gets current path server path)

Source: Internet
Author: User
Here are some of the sorting, PHP to get the path of the small knowledge, hope to help you!

1,$_server["query_string") Description: Query string 2,$_server["Request_uri"] Description: The uri3,$_server["Script_name" required to access this page Description: Contains the path of the current script 4,$_server["php_self" description: The file name of the currently executing script

  

Demo:1
http://www.xxx.com/(open homepage directly) results: $_server["query_string"] = "$_server[" Request_uri "] ="/"$_server[" script_name "] ="/ index.php "$_server[" php_self "] ="/index.php "

Demo:2
Http://www.xxx.com/?p=1 (with Query) results: $_server["query_string"] = "p=1" $_server["request_uri"] = "/?p=1" $_server["Script_ NAME "] ="/index.php "$_server[" php_self "] ="/index.php "

Demo 3
Http://www.xxx.com/index.php?p=1&q=xxx Result: $_server["query_string"] = "p=1&q=xxx" $_server["request_uri"] = " /index.php?p=1&q=xxx "$_server[" script_name "] ="/index.php "$_server[" php_self "] ="/index.php "

$_server["Query_string"] gets the query statement, in the instance, gets the following value $_server["Request_uri"] gets the value after http://www.xxx.com, including/$_server[" Script_name "] Gets the path to the current script, such as: index.php $_server[" Php_self ") the file name of the currently executing script

Current URL: "/http". $_server[' http_host '].$_server[' php_self ']

To summarize, for Query_string,request_uri,script_name and php_self, deep understanding will help us to correctly invoke these four values in the $_server function. The differences between the four variables are mastered by Query_string,request_uri,script_name and php_self in the $_server function by example.

$_server["Request_uri"]: Gets the full "except domain name" URL for the current request

A little bit of an unknown place, please point out ...

The above describes the ph to get the current URL path and server path summary (URL to get the current path server path), including the content, I hope to be interested in PHP tutorial friends helpful.

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