I know in php 5.4 there is a new function http_response_code(), but in prior versions how would you get a response code you just set?
Similar to Is there any way to get the current HTTP response code from PHP?
I have this need:
//sometime earlier
header('HTTP/1.1 404 Not Found');
//sometime later, detect if error was set
$status = some_magic_way_to_find_status();
Does anyone have a way in php 5.3 or below to do this?
I don’t think it’s possible.
You could wrap the
header()function:Or, of course, you could always upgrade to PHP5.4.