未定义的索引HTTP_HOST,即使已检查 [英] Undefined index HTTP_HOST even though it is checked

查看:85
本文介绍了未定义的索引HTTP_HOST,即使已检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

代码如下:

if (isset($_SERVER['HTTP_HOST']) === TRUE) {
  $host = $_SERVER['HTTP_HOST'];
}

如何在if语句内的行上获取未定义的索引HTTP_HOST"?我的意思是,在使用索引设置之前会对其进行检查.

How is it possible to get an "Undefined index HTTP_HOST" on the line inside the if statement? I mean, the index setting is checked before it is used.

为什么有时不能设置HTTP_HOST?

And why could the HTTP_HOST sometimes be not set?

推荐答案

您是否正在使用PHP-CLI?

Are you using PHP-CLI?

HTTP_HOST仅在浏览器上有效.

HTTP_HOST works only on the browser.

这篇关于未定义的索引HTTP_HOST,即使已检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆