Home  >  Article  >  Backend Development  >  What should I do if php cannot write Chinese?

What should I do if php cannot write Chinese?

藏色散人
藏色散人Original
2022-01-27 10:02:322888browse

Solution to why php cannot write Chinese: 1. Set the encoding of html page and php page to "charset=utf-8"; 2. Change the client through "mysql_query("set names utf8");" end encoding.

What should I do if php cannot write Chinese?

The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer

What should I do if php cannot write Chinese?

1. The garbled code problem in the html page itself

The solution is to use the pure html page

<meta http-equiv="Content-type=text/html;charset=utf-8"/>

2. The garbled code problem in the php page itself

header("Content-type=text/html;charset=utf-8");

3. Change the client's encoding.

mysql_query("set names utf8"); // 写到我们获取数据之前即可。

Recommended learning: "PHP Video TutorialCourse"

The above is the detailed content of What should I do if php cannot write Chinese?. 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