weicool
weicool

Reputation: 2773

PHP Not Recognizing http_get_request_headers()?

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?

Upvotes: 6

Views: 10211

Answers (4)

cwd
cwd

Reputation: 54756

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

Upvotes: 3

Gumbo
Gumbo

Reputation: 655129

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

Upvotes: 0

Seb
Seb

Reputation: 25147

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

Upvotes: 1

soulmerge
soulmerge

Reputation: 75704

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.

Upvotes: 5

Related Questions