$ _SERVER variable does not set my own header

I came across a very strange situation: I have an Apache server configured on 3 different computers, one is Ubuntu, the other is Mac, and the other is Windows 8, I'm trying to send a very simple post, request your own header, for example X_USER, in a PHP script ( the same script is in 3 machines), now to get my title, I use $_SERVERvar like $_SERVER['HTTP_X_USER'], however on Mac I get the values ​​just fine, but on the other two machines the value does not exist, I did var_dump in $_SERVERvar, and I can confirm that there are no headers, I did not configure anything interesting, just the default values.

Can someone tell me if I need to configure something, or am I accessing var the wrong way, or why I am not getting the header, maybe this is something at the Apache or php level, thanks for any help !!

+4
source share
2 answers

Well, I think I found the reason, I sent the headers as X_REST_USERNAME, for example, however in apache version 2.4_x the headers should use a dash, because the separators instead emphasize how it is X-REST-USERNAME, I have apache 2.2 on mac and others have version 2.4, however, in both versions the dash separator works fine, I did not know all this, thanks to everyone!

+5
source

Try

$headers = apache_request_headers();
echo $headers['x_user'];
+1
source

All Articles