search
Homephp教程php手册PHP判断服务器SSL是否启用,也就是判断是否支持HTTPS连接

PHP判断服务器SSL是否启用,也就是判断是否支持HTTPS连接

通过php函数来检测服务器是否支持SSL(即HTTPS连接),具体函数代码如下。另外关于如何开启SSL支持可参照本站文章:

php检测服务器SSL是否开启以及开启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;
}

例如:

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

您可能感兴趣的文章

  • php判断字符串是否全英文,纯中文,中英文组合的方法
  • php检测服务器SSL是否开启以及开启SSL的方法
  • php判断日期格式是否正确的方法总结
  • 如何知道服务器是否支持Gzip压缩
  • PHP实现同服务器多个二级域名共享 SESSION 数据
  • php如何判断当前的操作系统是linux还是windows
  • php判断远程文件是否存在的办法
  • php性能优化:使用 isset()判断字符串长度速度比strlen()更快
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.