Answers for "Undefined index: HTTP_HOST"

PHP
1

Undefined index: HTTP_HOST

/* 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'];
}
Posted by: Guest on September-22-2020

Code answers related to "Undefined index: HTTP_HOST"

Browse Popular Code Answers by Language