function is_HTTPS(){ if(!isset($_SERVER['HTTPS'])) return FALSE; if($_SERVER['HTTPS'] === 1){ //Apache return TRUE; }elseif($_SERVER['HTTPS'] === 'on'){ //IIS return TRUE; }elseif($_SERVER['SERVER_PORT'] == 443){ //其他 return TRUE; } return FALSE; }
也有这样用的:
if (strtoupper($_SERVER['HTTPS']) == 'ON') { ... }
转载于:https://blog.51cto.com/jhomephper/1621808