Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Not Recognizing http_get_request_headers()?

Tags:

http

php

I'm calling http_get_request_headers() in a PHP file on a server running PHP 5. However, I'm getting Fatal error: Call to undefined function http_get_request_headers(). Does anyone know what the problem might be? Does this function not come with plain PHP?

like image 957
weicool Avatar asked Mar 11 '09 17:03

weicool


3 Answers

No it does not. You need a PECL module for that function to work. But you can use the contents of the $_SERVER variable as stated in this comment on the php site. Alternatively you can use the apache function if this is your web server.

like image 65
soulmerge Avatar answered Oct 25 '22 05:10

soulmerge


If you're using version >= 2 of pecl_http you'll need to use the namespace syntax for calling the functions. Check out the version 2 documentation here and example here

Basically \http\Env::getRequestHeader()

like image 27
cwd Avatar answered Oct 25 '22 03:10

cwd


That function is part of the PECL extension.

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

like image 34
Seb Avatar answered Oct 25 '22 05:10

Seb