user1108996 user1108996 - 1 year ago 142
PHP Question

PHP File Encoding

I recently noticed that the file encoding of the pages I create in my editor are all over the place. Some are saved as ANSI, some are "UTF-8 Without BOM". I am referring to PHP, HTML, CSS, JavaScript files.

What is the best format to save my files in?

Answer Source

The advised way to go is to use UTF-8 everywhere in your web application. It includes :

  • File encoding
  • Database charset and encoding
  • String handling
  • HTML charset output

A nice cheatsheet :

Edit : Just want to add, related to your question context, that PHP don't handle file encoding in UTF-8 with BOM. Use UTF-8 without BOM and you'll be just fine.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download