Skip to content

Instantly share code, notes, and snippets.

@CodeNegar
Created August 25, 2012 08:54
Show Gist options
  • Save CodeNegar/3462679 to your computer and use it in GitHub Desktop.
Save CodeNegar/3462679 to your computer and use it in GitHub Desktop.
php: current page url
<?php
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;
}
?>
<?php
echo curPageURL();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment