I have the following code
protected function parse($header) {
$headerArr = http_parse_headers($header);
foreach ($headerArr as $key => $value) {
echo $key.'=>'.$value;
}
}
where $header is a http header. This code is in a PHP Class in a symfony2 project. I can execute it in a browser an get the expected results the keys and values of the parsed header like this
- Response Code=>200
- Response Status=>OK
- Date=>Sun, 13 Jul 2014 21:39:51 GMT
- Server=>Apache/2.4.7 (Ubuntu)
- Last-Modified=>Wed, 26 Mar 2014 22:51:46 GMT
- Etag=>502-4f58a50290480
- Accept-Ranges=>bytes
- Content-Length=>1282
- Content-Disposition=>attachment; filename= mvc.zip
- Keep-Alive=>timeout=5, max=100
- Connection=>Keep-Alive
- Content-Type=>application/zip
The problem is when i try to run a unit test for the function parse(), the PHPUnit can't find the http_parse_headers() function an throws "PHP Fatal error: Call to undefined function http_parse_headers()
How is this posible? How can I fix it?