I am studying UTF8 character set handling, and it is recommended that you explicitly specify the encoding type in the output headers in your PHP script as follows:
header('Content-Type: text/html; charset=utf-8');
My question is where should I place this heading. I have a configuration file that goes into every script and runs first. Should I place it at the top of this file so that this header is included first in every php file?
Will this affect my ability to set other headers, including the location of the header being redirected by line? Or should I place this immediately before any html output, for example, rendering my template file? That is, can this header be in place before any other php processing and what are the consequences of this? Does it affect the server side or just the encoding of the output?
Thank.
source
share