// Method 1:
PDO::__construct($dsn, $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8';"));
// Method 2:
PDO::__construct($dsn, $user, $pass);
PDO::exec("SET NAMES 'utf8';");
Both methods can be used To solve the problem, the principle is the same, whichever one you use depends on your preference
http://www.bkjia.com/PHPjc/320275.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320275.htmlTechArticle// Method 1: PDO::__construct($dsn, $user, $pass, array(PDO:: MYSQL_ATTR_INIT_COMMAND = "SET NAMES 'utf8';")); // Method 2: PDO::__construct($dsn, $user, $pass); PDO::exec("SET NAM...
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