Created
March 31, 2014 04:38
-
-
Save kythin/9885415 to your computer and use it in GitHub Desktop.
HTTP/HTTPS (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
<?php | |
/** | |
* http | |
* Echo's or returns the http starter section of the url. | |
* Use this to prevent SSL errors where some stuff is http and some is https. | |
* @param bool $return | |
* @return string | |
*/ | |
function http($return = false) { | |
$http = "http://"; | |
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') { | |
$http = 'https://'; | |
} | |
if ($return) { | |
return $http; | |
} else { | |
echo $http; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment