How to set utf8 in php pdo

藏色散人
Release: 2023-03-14 09:38:02
Original
2027 people have browsed it

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();
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!