A custom HTTP header was added at the time of the client request, as follows:
Custom HTTP request Headers
Var_dump (getallheaders);
It started with the getallheaders parameter, but found that it was not available on Nginx deployed servers, and it was very strange to see the PHP manual found that getallheaders this function only supports Apache servers. Then find a compatible method:
if (!function_exists (' getallheaders ')) {function getallheaders () {$headers = array (); foreach ($_server as $name = = $va Lue) {if (substr ($name, 0, 5) = = ' Http_ ') {$headers [Str_replace (', '-', Ucwords (Strtolower (' _ ', ' "," Str_replace ( $name, 5)))])] = $value;}} return $headers;}} Var_dump (Getallheaders ());
In fact, this method is to find the $_server variable in the beginning of the Http_ property, the property to do a string substitution. The http_user_id in the $_server variable is actually the custom User-id above:
$_server Variables in PHP
In addition to the custom HTTP header, you need to pay attention to the naming specification of the header, cannot be named under the underscore, otherwise under the Nginx server can not read, when looking for the naming specification, there is a reference to the custom attribute X-Start the problem. Later, I looked up some information and found that the subsequent HTTP protocol was not recommended.
The above content is for PHP getallheaders unable to get the custom header (headers) of the relevant narrative, I hope to help you!
The above describes the PHP getallheaders can not get the custom header headers problem, including the content, I hope that the PHP tutorial interested in a friend helpful.