Home >Backend Development >PHP Problem >What to do if php pdo mysql is garbled
php The solution to the garbled pdo mysql code is to add charset=utf8 to the statement when instantiating the pdo object. The statement is such as "new PDO('dblib:host=your_hostname;dbname=your_db;charset=UTF8' ”.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
What should I do if pdo mysql is garbled?
php uses PDO to query the mysql database and the result is Chinese garbled characters
The Chinese characters have become question marks
Solution:
Add in the statement when instantiating the pdo object charset=utf8
$db = new PDO('dblib:host=your_hostname;dbname=your_db;charset=UTF8', $user, $pass);
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of What to do if php pdo mysql is garbled. For more information, please follow other related articles on the PHP Chinese website!