Search code examples
phphttpresponse

How to get the status message set by http_response_code in PHP


The http_response_code function sets the header to the defined code and corresponding message from this map http_status_codes.h.

Is it possible to get the message?


Solution

  • Under Apache, you may try with apache_request_headers(). Otherwise, that information might well not be available at all (i.e. sent directly to whatever HTTP serving tier is there, out-of-band and unseen from ob_* functions).

    I don't think a definite general answer is possible without delving into the actual source code though.