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.