标题:
php json中文乱码的解决办法
[打印本页]
作者:
xiexie
时间:
2016-9-20 22:46
标题:
php json中文乱码的解决办法
做项目时,网页编码是gbk,ajax请求数据返回json数据时,如果对中文不做处理的话,返回乱码或者根本返回不了值,具体的做法如下。
$return = array();
if(mysql_fetch_array($que)) {
$sql = "UPDATE $table SET kai = '$kai' WHERE issue = '$issue' ORDER BY id DESC LIMIT 1";
mysql_query($sql);
$return['resCode'] = '0000';
$return['message'] = urlencode(iconv("GB2312","UTF-8//IGNORE",'更新成功'));
} else {
$return['resCode'] = '0001';
$return['message'] = urlencode(iconv("GB2312","UTF-8//IGNORE",'更新失败'));
}
echo urldecode(json_encode($return));
欢迎光临 PHP开发笔记 (http://phpvi.com/)
Powered by Discuz! 6.1.0