php - undefined index HTTP_HOST 即使它被选中

标签 php apache

代码如下:

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

如何在 if 语句内的行中获取“ undefined index HTTP_HOST”?我的意思是,索引设置在使用前会被检查。

为什么有时不能设置 HTTP_HOST?

最佳答案

你在使用 PHP-CLI 吗?

HTTP_HOST 仅适用于浏览器。

关于php - undefined index HTTP_HOST 即使它被选中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12347048/

相关文章:

php - 如何在 php 中的文本变量中使用样式?

javascript - 提交表单后如何留在页面上

php - 打印 $GLOBALS 时 "*RECURSION*"是什么意思?

java - Camel split xml 保留一些节点

apache - 在 Ubuntu 16.04.7 上将 Apache 2.4.18 升级到 2.4.26 或更高版本

php - 在独立的 php 和 apache 安装中使用 wamp 堆栈的 mysql

php - 如何在帖子中显示相册? [仅使用 PHP 和 MYSQL]

javascript - 使用 glob() 的 php/html5 播放列表

linux - CakePHP 中 OpenFlashChart2 的 FlashChartHelper : blank charts

regex - 如何使用 Apache 来阻止特定的 URL 类型?