Home > Backend Development > PHP Tutorial > php获取中文字符乱码,该怎么处理

php获取中文字符乱码,该怎么处理

WBOY
Release: 2016-06-13 13:08:31
Original
782 people have browsed it

php获取中文字符乱码
网页是GBK的,但要获取数据库里的中文字符是UTF-8的,请问转换的代码应当怎么写!


$z=mysql_query("select * from ttt_goods where site_id=1 ORDER BY id DESC LIMIT 0, 4");
while ($zow=mysql_fetch_row($z)){
$zow[3];
$new_tuan_threadlist[] = $zow;
}


其中$zow[3];是UTF-8的中文字符,去显示到GBK的网页都是乱码,网页只能是GBK的,请问怎么在PHP里把$zow[3]转过来,
知道的大哥帮忙下,小弟不怎么懂PHP,直接给代码谢谢了


------解决方案--------------------
$zow[3] = iconv('utf-8', 'gbk', $zow[3]);

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