DaGhostman Dimitrov
DaGhostman Dimitrov

Reputation: 1626

X-PHP-Response-Code Headers

I saw this header(X-PHP-Response-Code) here in this SO answer and was wondering.

  1. What is the function and are there any other X-PHP-* headers?
  2. If there are what is their function and usage (as much info as possible)?
  3. If this is the only one (in which I doubt) ignore 2.

Upvotes: 1

Views: 1287

Answers (2)

Jon
Jon

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

deceze
deceze

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

Related Questions