json_encode解析带中文的数组时会显示Unicode编码。如何解决呀?



 <?php  
include("conn.php");
$q=mysql_query("SELECT * FROM persion WHERE name ='王骏'"); 
while($e=mysql_fetch_assoc($q))
    $output[]=$e;
    print(json_encode($output));
mysql_close();

?>
这是我的代码,这样的话中文会乱码。


 [{"Id":"8","youxiang":"1","mima":"1","name":"\u738b\u9a8f","dengji":"4","sex":"","age":null,"taskTime":"0","major":"","phone":null,"QQ":null,"intro":null}]

中文乱码 jsonobject

东方萃妄想 10 years, 11 months ago

 json_encode($output, JSON_UNESCAPED_UNICODE)

PS. 这个是5.4.0之后才支持的

Local answered 10 years, 11 months ago

这样不很好吗,JS就好这口。

死蚂蚁MKII answered 10 years, 11 months ago

Your Answer