Skip to content

Instantly share code, notes, and snippets.

@ChrisMcKee
Created October 13, 2011 11:54
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ChrisMcKee/1284052 to your computer and use it in GitHub Desktop.
Save ChrisMcKee/1284052 to your computer and use it in GitHub Desktop.
Get site url with current protocol
<?php
function siteURL()
{
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$domainName = $_SERVER['HTTP_HOST'].'/';
return $protocol.$domainName;
}
define( 'SITE_URL', siteURL() );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment