Last active
December 12, 2015 00:48
-
-
Save mcbrwr/4686002 to your computer and use it in GitHub Desktop.
get current hostname in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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