Skip to content

Instantly share code, notes, and snippets.

@art2code
Created April 5, 2012 07:05
Show Gist options
  • Select an option

  • Save art2code/2308664 to your computer and use it in GitHub Desktop.

Select an option

Save art2code/2308664 to your computer and use it in GitHub Desktop.
Get Current URL With 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;
}
echo curPageURL();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment