How to get the whole url on the page in PHP

Here is a usefull function for getting current url:

function GetCurrentURL() {
$url = '';

if ($_SERVER["HTTPS"] == "on")
{
$url .= "https://";
}
else
{
$url .= "http://";
}
if ($_SERVER["SERVER_PORT"] != "80") {
$url .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$url .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $url;
}

No comments:

Post a Comment