Skip to content

Instantly share code, notes, and snippets.

@zoxon
Last active August 29, 2015 14:00
Show Gist options
  • Save zoxon/107c0b8bf31fb892d492 to your computer and use it in GitHub Desktop.
Save zoxon/107c0b8bf31fb892d492 to your computer and use it in GitHub Desktop.
PHP: Get current URL
function checkHTTPS() {
if(!empty($_SERVER['HTTPS'])) {
return ($_SERVER['HTTPS'] !== 'off') ? true : false;
}
else {
return ($_SERVER['SERVER_PORT'] == 443) ? true : false;
}
}
function getCurURI(){
$uri = (checkHTTPS()) ? 'https://' : 'http://';
$uri .= $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
return $uri;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment