/**
* 判断当前协议是否为 HTTPS
*/
function is_https()
{
if ( !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') {
return true;
} elseif ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) {
return true;
} elseif ( !empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') {
return true;
}
return false;
}
echo domain();//https://www.itqaq.com
/**
* 获取包含网址协议的域名
*/
function domain()
{
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https' : 'http';
return $http_type . '://' . $_SERVER['HTTP_HOST'];
}
function is_https()
{
return 'https:' == location.protocol ? true: false;
}
var domain = location.protocol + '//' + location.host