// 如果是https 连接返回true ,否则返回false
public function isHttps() {
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;
}
Use PHP to determine whether the user has enabled the HTTPS protocol.
HTTPS (full name: Hypertext Transfer Protocol Secure [5] ) is an HTTP channel aimed at security, which ensures the security of the transmission process through transmission encryption and identity authentication on the basis of HTTP [1]. HTTPS adds SSL on the basis of HTTP, and the security basis of HTTPS is SSL, so the detailed content of encryption requires SSL. HTTPS has a different default port than HTTP and an encryption/authentication layer (between HTTP and TCP). The system provides authentication and encrypted communication methods. It is widely used in security-sensitive communications on the World Wide Web, such as transaction payments [2].