1. Whether the project file is utf8 encoded
Right-click the project file->properties->Resource->Text file encoding- >Set to utf8
2. Whether the page content is utf8 encoded
Add in the
tag:<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
The above two steps It can basically solve the problem of local pages displaying Chinese.
3. Whether the database uses utf8 encoding
If a database is used, the database must also use utf8 encoding. That is, when creating a table, the character set must be utf8. .
4. Whether to use ut8 encoding during transmission to the database
The local page uses utf8 encoding, and the remote database also uses utf8 encoding, but Chinese characters may still appear In the case of garbled characters, it is necessary to use utf8 encoding during the transmission process. The method is to establish a database connection and execute:
mysql_query("set names 'utf8'");//在插入数据执行前添加 mysql_query("set character_set_client=utf8"); mysql_query("set character_set_results=utf8");
Recommended tutorial: PHP video tutorial
The above is the detailed content of PHP cannot display Chinese characters. For more information, please follow other related articles on the PHP Chinese website!