php判断当前访问地址的访问协议是否是https
/**
* 判断当前访问地址的访问协议是否是https
*
* @para string $string
*
* @return string
*/
if (!function_exists('is_https')) {
function is_https() {
// return ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? TRUE : FALSE;
if (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443) {
return TRUE;
}elseif (!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;
}
}
当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »