pdo->prepare("set names utf8");"."/> pdo->prepare("set names utf8");".">

Home  >  Article  >  Backend Development  >  How to set utf8 in php pdo

How to set utf8 in php pdo

藏色散人
藏色散人Original
2021-12-02 10:48:292022browse

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");" .

How to set utf8 in php pdo

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!

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