使用$ _SERVER ['HTTPS']的未定义索引错误 [英] Undefined index error using $_SERVER['HTTPS']
本文介绍了使用$ _SERVER ['HTTPS']的未定义索引错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
调试抛出...
注意:未定义的索引:HTTPS中 C:\ xampplite \ htdocs \ testsite \ wp-content \ themes \ mytheme \ header.php 在第4行
Notice: Undefined index: HTTPS in C:\xampplite\htdocs\testsite\wp-content\themes\mytheme\header.php on line 4
如何在下面更改我的功能以防止发生错误?
How can I change my function below to prevent the error?
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
}
这等效吗?
if ( isset( $_SERVER["HTTPS"] )) {$pageURL .= "s";}
推荐答案
Some servers simply don't set $_SERVER['HTTPS']
if the request is non-secure. Some others may set it to 'off'
. You'll have to check it like this:
if ( isset( $_SERVER["HTTPS"] ) && strtolower( $_SERVER["HTTPS"] ) == "on" ) {
$pageURL .= "s";
}
这篇关于使用$ _SERVER ['HTTPS']的未定义索引错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文