Reputation: 35235
I can set "charset" on the back end (PHP):
header('charset=utf-8');
I can also set it on the front end (HTML):
<meta charset="UTF-8">
Where should I set it and why?
Upvotes: 0
Views: 502
Reputation: 10841
You can also set it at the server level in your Apache or Nginx or whatever configuration.
The short answer is that it doesn't matter that much for most user-facing browser use cases. Most browsers will interpret both the back-end and front-end charset tags the same.
That being said, setting the tag on the back-end is preferable in many instances. It slightly decreases the total amount of HTML that is sent to the user, it will show up in a HEAD http request, and such. Additionally, some other meta tags, such as the X-UA-Compatible meta tag, behave strangely in some cases if set on the front-end.
Upvotes: 3