Here\'s the code:
if (isset($_SERVER[\'HTTP_HOST\']) === TRUE) {
$host = $_SERVER[\'HTTP_HOST\'];
}
How is it possible to get an \"Undefined
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'];
}
For detailed info take a look here https://shiflett.org/blog/2006/server-name-versus-http-host