code is as follows |
copy code |
<?php Note: Get no parameter URL function Curpageurl () { $pageurl = ' http '; if ($_server["https tutorial"] = = "on") { $pageurl. = "S"; } $pageurl. = "://"; if ($_server["Server_port"]!= "80") { $pageurl. = $_server["SERVER_NAME"]. ":". $_server["Server_port"]. $_server[' php_self ']; } Else { $pageurl. = $_server["SERVER_NAME"]. $_server[' php_self ']; } return $pageurl; } ?> |
Method Two
code is as follows |
copy code |
<?php //Description: Get full URL Function Curpageurl () { $pageurl = ' http '; if ($_server["https"] = = "on") { $pageurl. = "S"; } $pageurl. = "://"; if ($_server["Server_port"]!= "no") { $pageurl. = $_server["SERVER_NAME"]. ":" . $_server["Server_port"]. $_server["Request_uri"]; } Else { $pageurl. = $_ server["SERVER_NAME"]. $_server["Request_uri"]; } return $pageurl; } |
Additionally, $_server[' Request_uri '] and $_server[' Request_url ' are slightly different:
$_server["Request_uri" returns the full path (/directory/ file.ext?query=string)
$_server[' Request_url '] returns only the file path, excluding parameters, (/directory/file.ext), and $_server[' php_self '] almost, Only $_server[' Request_url ' is not available on some servers