PHP中json_encode中文乱码问题
定义以下函数:function show($status, $message,$data=array()) {
$result = array(
'status' => $status,
'message' => urlencode($message),
'data' => $data,
);
exit(urldecode(json_encode($result)));
}
调用之后:
show(0,"用户名不能为空");
结果如下:
{"status":0,"message":"鐢ㄦ埛鍚崭笉鑳戒负绌猴紒","data":[]}
若是改为:
function show($status, $message,$data=array()) {
$result = array(
'status' => $status,
'message' => $message,
'data' => $data,
);
exit(json_encode($result, JSON_UNESCAPED_UNICODE));
}
调用之后:
show(0,"用户名不能为空");
结果还是一样:
{"status":0,"message":"鐢ㄦ埛鍚崭笉鑳戒负绌猴紒","data":[]}
以上是网上搜罗的两种方法,用以解决json_encode中文乱码问题,但是都不管用,请问还有什么办法可以解决?