Home >Backend Development >PHP Tutorial >PHP determines whether the server SSL is enabled, that is, whether it supports HTTPS connection_PHP tutorial

PHP determines whether the server SSL is enabled, that is, whether it supports HTTPS connection_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 09:57:261636browse

PHP determines whether the server's SSL is enabled, that is, whether it supports HTTPS connections.

Use the php function to detect whether the server supports SSL (that is, HTTPS connections). The specific function code is as follows. In addition, regarding how to enable SSL support, please refer to the article on this site:

php detects whether server SSL is enabled and how to enable SSL

/*
* 检测服务器是否支持SSL连接(Https连接)
* @return bool
*/
function is_SSL(){
	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;
}

For example:

echo is_SSL()?'支持':'不支持';

Articles you may be interested in

  • How to use php to determine whether a string is all in English, pure Chinese, or a combination of Chinese and English
  • php detects whether the server SSL is turned on and How to enable SSL
  • Summary of methods for PHP to determine whether the date format is correct
  • How to know whether the server supports Gzip compression
  • PHP enables multiple secondary domain names to share SESSION data with the same server
  • How to determine whether the current operating system is linux or windows in php
  • How to determine whether a remote file exists in php
  • php performance optimization: use isset() to determine the string length speed Faster than strlen()

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/982050.htmlTechArticlePHP determines whether the server SSL is enabled, that is, whether it supports HTTPS connection and uses the php function to detect whether the server supports SSL ( That is, HTTPS connection), the specific function code is as follows. Also close...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn