How to Get the Current Page URL in PHP
$CurrentURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$CurrentURL .= "s";}
$CurrentURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$CurrentURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$CurrentURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
echo $CurrentURL;
$CurrentURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$CurrentURL .= "s";}
$CurrentURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$CurrentURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$CurrentURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
echo $CurrentURL;
No comments:
Post a Comment