PHP File Encoding

I recently noticed that the encoding of the page files that I create in my editor is everywhere. Some of them are saved as ANSI, some of them are "UTF-8 without specification." I mean PHP, HTML, CSS, JavaScript files.

What is the best format to save my files?

+8
php encoding character-encoding
source share
4 answers

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

  • File encoding
  • Database Encryption and Encryption
  • Line processing
  • HTML encoding output

Good cheatsheet: http://developer.loftdigital.com/blog/php-utf-8-cheatsheet

Edit: I just want to add a context related to your question that PHP does not handle file encoding in UTF-8 using the specification. Use UTF-8 without specification, and you will be fine.

+4
source share

I will vote for UTF-8 without specification. Please note that if you use only regular English characters, ASCII and UTF-8 files will almost always be the same! This means that your editor can read the encoding as ASCII, even if you saved it as UTF-8.

+1
source share

If you do not do much CJK work, you should save your files in UTF-8 without specification.

0
source share

UTF-8 is what I use ...

This is best for English. http://en.wikipedia.org/wiki/UTF-8

0
source share

All Articles