1// Since PHP 5.4.0 you can use getallheaders function which returns all request headers as an associative array:
2
3var_dump(getallheaders());
4
5// array(8) {
6// ["Accept"]=>
7// string(63) "text/html[...]"
8// ["Accept-Charset"]=>
9// string(31) "ISSO-8859-1[...]"
10// ["Accept-Encoding"]=>
11// string(17) "gzip,deflate,sdch"
12// ["Accept-Language"]=>
13// string(14) "en-US,en;q=0.8"
14// ["Cache-Control"]=>
15// string(9) "max-age=0"
16// ["Connection"]=>
17// string(10) "keep-alive"
18// ["Host"]=>
19// string(9) "localhost"
20// ["User-Agent"]=>
21// string(108) "Mozilla/5.0 (Windows NT 6.1; WOW64) [...]"
22// }
1
2There's a polyfill for this that can be downloaded or installed via composer:
3
4https://github.com/ralouphie/getallheaders
5