PHP garbled problem Summary and solution
Garbled has always been a very big problem for PHP beginners, and now summarizes the reasons for the PHP website garbled and Solutions :
First, HTML page encoding:
Meta Http-equiv=content-type content=text/html; Charset=utf-8 the code here and database encoding, and connection database coding;
Second, the file storage code:
For example, file inde.php, changing its storage encoding to the desired encoding. Simply save the text-editing software file as EditPlus and select the correct encoding in the encoding
(Many people will ignore this);
Third, the database code:
For example, with phpMyAdmin Selecting a database, select the action option. The following is a collation, which should also be set to a unified code;
Four, the table code:
The operation is similar to the 3rd. There is no repetition here;
Five, field code:
In the construction of the table in the field, there is a collation. If the content has Chinese characters, it must be changed to a unified code;
Vi. database operation encoding settings:
When connecting to the database mysql_select_db (), add a sentence mysql_query (set names UTF8);
Seven, the local test after the successful website, to go online, there will be garbled.
It may be that the correct encoding is not selected when the data is exported locally, so there is a garbled problem after importing to the Web.
In fact, as long as careful, you can completely solve the PHP garbled problem, difficult is not technology, but careful.