加入header("content-type:text/html; charset=utf-8");echo不乱码,但是数据库查询就乱了,怎么办?
数据分析师2017-10-01 00:28:25
Add header("content-type:text/html; charset=utf-8"); the echo is not garbled, but the database query is messed up. What should I do? -PHP Chinese website Q&A-Add header("content-type:text/html; charset=utf-8"); the echo is not garbled, but the database query is messed up. What should I do? -PHP Chinese website Q&A
Let’s take a look and learn.
怪我咯2017-02-21 13:29:15
在你链接数据库的下方加入查询数据库指定编码 ,向下面这样
$link = mysqli_connect('localhost','root','密码','数据库名') ;
$link->query("SET NAMES utf8");