If you’re using the version 2
pecl_http (possibly version 2.0.6?) on your webserver, perhaps Ubuntu or CentOS, with PHP5, maybe 5.3, 5.4, or 5.5, you may have noticed that after getting it all installed and adding this to your
extension=raphf.so extension=propro.so extension=http.so
But then when you try and use the function
get_request_headers() you end up getting:
PHP Fatal error: Call to undefined function http_get_request_headers()
Well, when this extension switched to pecl/http v2 it changed a lot of things, and global functions was one of them. It now uses namespaces, and so instead of using
http_get_request_headers() you’ll need to use something like this:
$headers = \http\Env::getRequestHeader(); print_r($headers);
The check out the docs for more details on how to use the new function, basically you’ll see
getRequestHeader: Retrieve one or all headers of the current HTTP request.
Optional string $header_name
The key of a header to retrieve.
- NULL, if $header_name was not found
- string, the compound header when $header_name was found
- array of all headers if $header_name was not specified