php获取mysql汉语言后显示乱码,能帮修改一下吗

WBOY
Release: 2016-06-13 12:47:25
Original
722 people have browsed it

php获取mysql中文后显示乱码,能帮修改一下吗

<?php<br />
header("Content-type: text/html; charset=utf-8");<br />
$dsn = 'mysql:host=localhost;dbname=pw9';<br />
$db = new PDO($dsn,'root','');<br />
$rs = $db->query('SELECT * FROM pw_bbs_threads');<br />
while($row=$rs->fetch()){<br />
	print_r($row);<br />
}
Copy after login

1.文件编码utf8
2.mysql编码utf8
3.浏览器编码utf8

搜索了很多,发现有人说要set names utf8,可是在我这个代码里面不知道如何写,麻烦高人修改一下谢谢

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