Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php中检查页面是从http调用还是从https调用_Php - Fatal编程技术网

如何在php中检查页面是从http调用还是从https调用

如何在php中检查页面是从http调用还是从https调用,php,Php,只是想知道,我们是否可以在php中检查该页面是来自http还是https的调用 例如: 如果我通过以下链接调用page call customer.php,是否可以签入php并告知该页面来自http。。另外,如果我从下面的链接调用该页面,是否可以在php中进行检查并告知该页面来自https 试着看看: if (!empty($_SERVER['HTTPS'])) { // https is enabled } 您还可以检查$\u服务器['SERVER\u PORT']作为 与开始的HT

只是想知道,我们是否可以在php中检查该页面是来自http还是https的调用

例如: 如果我通过以下链接调用page call customer.php,是否可以签入php并告知该页面来自http。。另外,如果我从下面的链接调用该页面,是否可以在php中进行检查并告知该页面来自https

试着看看:

if (!empty($_SERVER['HTTPS'])) {
    // https is enabled
}

您还可以检查
$\u服务器['SERVER\u PORT']
作为

与开始的HTTP URL相反 使用“http://”,并通过使用端口80 默认情况下,HTTPS URL以开头 “https://”并通过使用端口443 默认


如果请求是通过HTTPS发送的,您将在
$\u服务器
超全局
-$\u服务器['HTTPS']中有一个额外的参数。
您可以检查是否设置了该参数

if( isset($_SERVER['HTTPS'] ) ) {
可能重复的
if( isset($_SERVER['HTTPS'] ) ) {