Reputation: 1626
I saw this header(X-PHP-Response-Code) here in this SO answer and was wondering.
Upvotes: 1
Views: 1287
Reputation: 437326
Headers starting with X-
are not standard and their interpretation is entirely dependent on a client that looks for them and knows what they are supposed to mean.
This particular header does not have any meaning, it's just placeholder text to satisfy an extra requirement of the header
function when a third argument http_response_code
is supplied:
http_response_code
Forces the HTTP response code to the specified value. Note that this parameter only has an effect if the string is not empty.
Upvotes: 2
Reputation: 521994
In the example given, the header does exactly nothing, which is exactly the point.
HTTP headers starting with X-
are precisely not standardized, so anyone can set such a header knowing that it doesn't mean anything specific. The point in the case you cite is simply to use the header
function to set the response code. To do that, some header needs to be supplied. The user chose to use the otherwise meaningless header X-PHP-Response-Code
, simply to be able to give some header to header()
in order to use its third argument to set the response code.
In other words: it's a hack.
Upvotes: 2