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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Atom editor mac version download

Atom editor mac version download

The most popular open source editor