Skip to content

Instantly share code, notes, and snippets.

@kythin
Created March 31, 2014 04:38
Show Gist options
  • Save kythin/9885415 to your computer and use it in GitHub Desktop.
Save kythin/9885415 to your computer and use it in GitHub Desktop.
HTTP/HTTPS (PHP)
<?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