6

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?

1
  • As stated in the php manual, (PECL pecl_http >= 0.10.0) Commented Mar 11, 2009 at 17:36

4 Answers 4

5

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.

Sign up to request clarification or add additional context in comments.

Comments

3

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()

1 Comment

This is a very important point. I followed the instructions in the PHP manual for installing pecl_http, but still the example for http_support() continued to fail. It's because the PHP manual is written for the old version of this module. Unfortunately, the new module has its own documentation, but it isn't very clear.
1

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

Comments

0

Have you read the Installation and Configuration guide for the HTTP classes/functions?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.