json_encode()函数为什么不能解析带中文的JSON字符串呢?
这样就有值:
- PHP code
<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$a = '{ "a":"www", "b":2}';$arr = json_decode($a, true);
这样就返回NULL:
- PHP 本文来源gaodai#ma#com搞@@代~&码*网/搞gaodaima代码code
<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$a = '{ "a":"你好", "b":2}';$arr = json_decode($a, true);
为什么出现这种情况呢?该怎么解析带中文的JSON字符串呢?
——解决方案——————–
在你的编辑器中把字符集改为utf-8
——解决方案——————–
文件编码 utf-8 或者 iconv 自己再转