In the Apache config, one can set the following directive to cause the httpd to always send a UTF-8 character encoding header for text/html and text/plain MIME types:
AddDefaultCharset utf-8
I would like to be able to detect in my PHP scripts whether or not this header is being sent, so that I can send the same header using the header()
function if it hasn't been sent.
How can I detect this?
Information provided by deceze in the comments on the initial question negated a need for an answer. However, for the sake of completeness, I would say that it appears that there isn't an obvious way to detect if headers have been sent by Apache from within PHP... but, given the above information, I can't think of a reason why you'd need to.
There's apache_response_headers(), though it'll only report on headers that are already "in play". If your charset header is added after the fact, you'd never see it.