Get a URL address in PHP I will use the Super global variable $_server, he includes a variety of parameters, such as Http_host, php_self, query_string, etc., here is not introduced.
PHP gets the URL of a few functions introduced
| The code is as follows |
Copy Code |
Get domain name or host address echo $_server[' Http_host ']. " "; Get web Address echo $_server[' php_self ']. " "; Get URL parameters echo $_server["Query_string"]. " "; Detailed address of the source page echo $_server[' Http_referer ']. " "; ?> |
Combine the above several functions to get the full URL address
| The code is as follows |
Copy Code |
Description: Get the full URL function Curpageurl () { $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; } ?> |
Once you have defined the function, you can call it directly:
| The code is as follows |
Copy Code |
Echo Curpageurl (); ?> |
http://www.bkjia.com/PHPjc/633120.html www.bkjia.com true http://www.bkjia.com/PHPjc/633120.html techarticle get a URL address in PHP I will use the Super global variable $_server, he includes a variety of parameters, such as Http_host, php_self, query_string, etc., here is not introduced. PHP get ...