PHP json_encode 中文乱码

WBOY
Release: 2016-06-23 13:59:47
Original
867 people have browsed it

如标题,  这个问题不用urlencode()的方式该怎样解决?      
              希望各位指教指教。


回复讨论(解决方案)

首先那不是乱码,而是 unicode 的符号表示
如果希望仍保留中文字样,那么递归应用 urlencode 是最佳选择,同时还使数据不限与 utf-8 编码

当然你也可以对 json_encode 的结果做一下编码逆转换,但涉及正则,效率要低些

如果你使用的是 php5.4 及以上,就简单了
只需给 json_encode 加上第二个参数: JSON_UNESCAPED_UNICODE

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