Skip to content

Instantly share code, notes, and snippets.

@raynimmo
Created January 27, 2014 04:48
Show Gist options
  • Save raynimmo/45f1d6ef0249f105ba31 to your computer and use it in GitHub Desktop.
Save raynimmo/45f1d6ef0249f105ba31 to your computer and use it in GitHub Desktop.
PHP get current page URL
function getUrl() {
$url = @( $_SERVER["HTTPS"] != 'on' ) ? 'http://'.$_SERVER["SERVER_NAME"] : 'https://'.$_SERVER["SERVER_NAME"];
$url .= ( $_SERVER["SERVER_PORT"] !== 80 ) ? ":".$_SERVER["SERVER_PORT"] : "";
$url .= $_SERVER["REQUEST_URI"];
return $url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment