Home >Backend Development >PHP Tutorial >mysql读取数据后编码有问题,求高手

mysql读取数据后编码有问题,求高手

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 14:11:45891browse

smarty 编码 数据库 MySQL


这是我注册的一个smarty函数
function charsetUTF8($params) {								extract($params);										$str=iconv("gb2312","UTF-8",$text);	return $str;										}$smarty->register_function("Util", "charsetUTF8");	   				





{section name=gro_id loop=$gro}				 						         <option value="{$gro[gro_id].id}">{Util text=$gro[gro_id].u_group}</option>									{/section}



可读出来的是乱码



现在数据库的字段编码是gb2312,文件开头也有规定编码,为什么出问题啊
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


我试过将数据库的编码改为utf-8,不使用我注册的那个smarty函数,还是有问题,求助各位大神。。。

回复讨论(解决方案)

echo  charsetUTF8($params);  这里乱码吗

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