Skip to content

Instantly share code, notes, and snippets.

@outman
Created October 18, 2012 06:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save outman/3910157 to your computer and use it in GitHub Desktop.
Save outman/3910157 to your computer and use it in GitHub Desktop.
site domain
class Util {
static function domain($output = true) {
$protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https');
$host = $_SERVER["HTTP_HOST"];
$port = $_SERVER["SERVER_PORT"];
$domain = (($protocol !== false) ? "https" : "http") . "://" . $host;
$domain .= ($port == "80") ? "" : (":" . $port);
return $domain;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment