Skip to content

Instantly share code, notes, and snippets.

@mcbrwr
Last active December 12, 2015 00:48
Show Gist options
  • Save mcbrwr/4686002 to your computer and use it in GitHub Desktop.
Save mcbrwr/4686002 to your computer and use it in GitHub Desktop.
get current hostname in PHP
function currentHostname() {
isset($_SERVER['HTTPS']) ? $pageURL = 'https://' : $pageURL = 'http://';
$pageURL .= $_SERVER['SERVER_PORT'] != '80' ? $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"] : $_SERVER['SERVER_NAME'];
return $pageURL;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment