Undefined index HTTP_HOST even though it is checked

前端 未结 5 2268
栀梦
栀梦 2021-02-18 13:17

Here\'s the code:

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

How is it possible to get an \"Undefined

5条回答
  •  天涯浪人
    2021-02-18 13:59

    The HTTP_HOST must always be set if you are running on a browser... then there is no need to check... simply,

    $host = $_SERVER['HTTP_HOST'];
    

    is enough

提交回复
热议问题