时间:2021-07-01 10:21:17 帮助过:93人阅读
为了防止乱码,我在为db设罢了好几个字符集:
mysqli_query($db,"SET NAMES UTF8");
mysqli_query($db,"set character_set_client=utf8");
mysqli_query($db,"set character_set_connection=utf8");
mysqli_query($db,"set character_set_results=utf8");
不过看到一个文章是这样说的:
http://zhangxugg-163-com.iteye.com/blog/1835721
按上面的描述,一条SET NAMES UTF8
是不是就已经等于set character_set_client=utf8; set character_set_connection=utf8; set character_set_results=utf8;
这三条呢?
大家讨论下
.`
为了防止乱码,我在为db设罢了好几个字符集:
mysqli_query($db,"SET NAMES UTF8");
mysqli_query($db,"set character_set_client=utf8");
mysqli_query($db,"set character_set_connection=utf8");
mysqli_query($db,"set character_set_results=utf8");
不过看到一个文章是这样说的:
http://zhangxugg-163-com.iteye.com/blog/1835721
按上面的描述,一条SET NAMES UTF8
是不是就已经等于set character_set_client=utf8; set character_set_connection=utf8; set character_set_results=utf8;
这三条呢?
大家讨论下
.`
set NAMES utf8
show variables like "character_set_%"
操作显示是这样的
如上回答,改变了character_set_client/character_set_connection/character_set_results三个值
是的,一条命令等于你所列的3条,主要确保编码一致性不乱码