📜  未定义索引:HTTP_HOST - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:50.409000             🧑  作者: Mango

代码示例1
/* When a request is done with an empty host:

GET / HTTP/1.1
Host:
Then isset($_SERVER['HTTP_HOST']) is true!

It is better to use empty like:*/

$host = '';
if (!empty($_SERVER['HTTP_HOST'])) {
  $host = $_SERVER['HTTP_HOST'];
}