Sunny Khan Sunny Khan - 6 months ago 28
PHP Question

Why $http_response_header does not returns response header of the current page?

Under PHP VERSION 7.1.0

As i know that

returns an associative array of response headers BUT when i simply put
alone into my php file then it says
Notice: Undefined variable: http_response_header in C:\xampp\htdocs\myfiles\Research\index.php on line 2
instead of returning this error it should return the response headers of the current page that are receieved by the server localhost

But using it on
it works fine.

I am already at on that issue, so please don't share the links to in the answer.

Can anyone tell in easy words why is that happening ?

Answer Source

Even though you asked for not redirecting you back to, I will still do that:

When using the HTTP wrapper, $http_response_header will be populated with the HTTP response headers.

This means, you have to use a Wrapper in your php script. Calling your document triggers a GET to your Apache but not a wrapper in your script.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download