Home  >  Article  >  Backend Development  >  Solution to php pdo encoding garbled problem

Solution to php pdo encoding garbled problem

WBOY
WBOYOriginal
2016-07-25 08:54:421055browse
  1. mysql_query(“set names utf8″);
Copy code

So, use the same method as above. Solve the problem of Chinese garbled characters in pdo.

  1. $db = new PDO($dbconn['dns'],$dbconn['dbuser'],$dbconn['dbpwd']);
  2. $db->query("set names utf8″ );
Copy the code

In this way, the pdo encoding problem is solved.

Summary: PHP Chinese garbled problems, PDO Chinese garbled problems, MySQL Chinese garbled problems, etc., all of them basically did not support Chinese at the beginning. In the future, when Chinese becomes more powerful, we can develop a Chinese programming tool. For example: if (1==1) { implement. . . }



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