Is there a particular order in PHP to set HTTP headers with the header() function ?
I mean, for example, must I call
header('Content-Language: en');
before
header('Content-Type: text/plain');
or does the order not matter?
My guess is that order isn’t important as long as all the headers are set before any content is outputted, but I just want to be sure that’s the case…
No, the order of the header fields doesn’t matter:
Only if you’re sending multiple fields of the same name. Then the field values are treated like they would appear in one list:
So the following:
would be equivalent to:
And here it depends on the definition of the header field (here Cache-Control) if the order does matter.