Home >Backend Development >PHP Problem >What should I do if php cannot write Chinese?
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.
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!