PHP Determines whether server SSL is enabled, which is to determine whether HTTPS connections are supported

Source: Internet
Author: User
Tags return ssl connection

Through the PHP function to detect whether the server supports SSL (that is, HTTPS connection), the specific function code is as follows. Also about how to turn on SSL support can refer to this site article:

PHP detects whether the server SSL is turned on and how to turn on SSL

*
* Detect whether the server supports SSL connection (HTTPS connection)
* @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) {//other return
		TRUE;
	}
	return FALSE;
}

For example:

echo Is_ssl ()? ' Support ': ' Not supported ';

Articles that you may be interested in

  • PHP detects whether the server SSL is turned on and how to turn on SSL
  • PHP to determine whether the string is full English, pure Chinese, in combination with the English method
  • A summary of how PHP determines whether the date format is correct
  • How to know if the server supports gzip compression
  • How PHP determines whether the current operating system is Linux or Windows
  • PHP to determine whether a remote file exists
  • PHP implementation of the same server with multiple two-level domain share session data
  • PHP Analysis file header information to determine the type of upload file


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.