pdo->prepare("set names utf8");"."/> pdo->prepare("set names utf8");".">
Home >Backend Development >PHP Problem >How to set utf8 in php pdo
php pdo method to set utf8: 1. Open the corresponding PHP code file; 2. Set the utf8 encoding through "$this->pdo->prepare("set names utf8");" .
The operating environment of this article: Windows7 system, PHP7.4 version, DELL G3 computer
How to set utf8 on php pdo?
Solving the Chinese garbled problem with PDO in PHP
Set utf8:
$this->pdo = new PDO($dsn, $user, $password, array(PDO::ATTR_PERSISTENT => true)); $stmt = $this->pdo->prepare("set names utf8"); $stmt->execute();
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to set utf8 in php pdo. For more information, please follow other related articles on the PHP Chinese website!