醉菜鸟 2021-07-07 08:32:24

PHP判断是否https

/**
* @return bool
*/
function isSsl()
{
if ($_SERVER['HTTPS'] && ('1' == $_SERVER['HTTPS'] || 'on' == strtolower($_SERVER['HTTPS']))) {
return true;
} elseif ('https' == $_SERVER['REQUEST_SCHEME']) {
return true;
} elseif ('443' == $_SERVER['SERVER_PORT']) {
return true;
} elseif ('https' == $_SERVER['HTTP_X_FORWARDED_PROTO']) {
return true;
}
return false;
}
意见反馈