I needed a way to unit test some code that sends HTTP headers via the header function.
However when doing this from the command line :
php -r "header('Foo : Bar'); print_r(headers_list());"
The only result you get is an empty array, which makes sense of course but for unit testing from the command line that is annoying.
XDebug saves the day again by providing the xdebug_get_headers function.
Let’s try the same code, but with XDebug this time :
php -r "header('Foo:Bar'); print_r(xdebug_get_headers());"
Returns
Array ( [0] => Foo:Bar )
Joy












