Reference website:
Http://www.neatstudio.com/show-377-1.shtml
PHP generally uses getallheaders to get the head, but in fact, some modes are not acquired (previously did not notice in fastcgi This function is not available, of course, I do not test now.) That's what Lao Wang said.
He said:
In PHP, to get all the HTTP request headers, you can use the Getallheaders method, but this method does not exist in any environment, for example, you use fastcgi way to run PHP, there is no such method, so we need to consider other methods, fortunately There's something we want in $_server, and it's the HTTP request header that starts with the key name HTTP_:
$headers = array();
foreach ($_SERVER as $key => $value) {
if (‘HTTP_‘ == substr($key, 0, 5)) {
$headers[str_replace(‘_‘, ‘-‘, substr($key, 5))] = $value;
}
}
The code is simple, and it is important to note that the name of the header is not case-sensitive in the RfC.
Use PHP to get all HTTP request headers