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

PHP cannot display Chinese characters

王林
Release: 2023-02-25 15:22:01
Original
4171 people have browsed it

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 tag:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Copy after login

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");
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template