Skip to content

Instantly share code, notes, and snippets.

@achudars
Last active December 17, 2015 00:19
Show Gist options
  • Save achudars/5520447 to your computer and use it in GitHub Desktop.
Save achudars/5520447 to your computer and use it in GitHub Desktop.
Get Current URL using PHP
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