to the head tag of the HTML file."/> to the head tag of the HTML file.">

Home  >  Article  >  Backend Development  >  PHP cannot display Chinese characters

PHP cannot display Chinese characters

王林
王林Original
2019-09-29 11:55:204099browse

PHP cannot display Chinese characters

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 93f0f5c25f18dab9d176bd4f6de5d30e 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 &#39;utf8&#39;");//在插入数据执行前添加
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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php shows errorNext article:php shows error