Home >Backend Development >PHP Tutorial >php PDO Chinese garbled solution_PHP tutorial

php PDO Chinese garbled solution_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:45:481022browse

// 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

www.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