Is there a way to get the current HTTP response code with PHP?

Is there a way to get the HTTP response code to be sent from a PHP script, for example a script like this:

header('HTTP/1.1 404 Not Found');

$code = imaginary-function(); // $code contains 404

I noticed a function http_response_codein PHP docs, but this doesn't seem to be available in PHP 5.3.9.

Thanks in advance!

+2
source share
3 answers

It apparently was added in PHP 5.4, but I did not confirm this.

+2
source

Starting with PHP 5.4, http_response_code()get or set a value.

0
source

headers_list ,

docs: - http://www.php.net/manual/en/function.headers-list.php

headers_list() , /. , , headers_sent().

headers_list , , (): -

http://www.php.net/manual/en/function.header-register-callback.php

-2
source

All Articles