PHP Doesn't recognize http_get_request_headers ()?

I call http_get_request_headers () in a PHP file on a server with PHP 5. However, I get Fatal error: calling the undefined function http_get_request_headers (). Does anyone know what the problem is? Does this function work with plain PHP?

+6
php
source share
4 answers

No no. For this feature to work, you will need a PECL module . But you can use the contents of the $ _SERVER variable as pointed out in this comment on the php site. Alternatively, you can use the apache function if this is your web server.

+5
source

If you are using version> = 2 from pecl_http , you need to use the namespace syntax to call the functions. Check out version 2 here and an example here

Basically \http\Env::getRequestHeader()

+3
source

This feature is part of the PECL extension.

Follow the instructions on this page to install it: http://ar.php.net/manual/en/http.install.php

+1
source

All Articles