登录 |  注册 |  繁體中文


json_decode解码失败

分类: php 颜色:橙色 默认  字号: 阅读(3233) | 评论(0)

今天在json_decode上纠结了半天,一直在用的json_decode突然返回null, 首先看了一下手册,

This function only works with UTF-8 encoded data.  以为是编码问题,

$strCode = mb_detect_encoding($str); 检测编码,然后用,iconv($strCode, "UTF-8", $str) //转成utf-8  结果还是失败

google了一下原来是, 字符串中含有 回车等隐藏的不可见字符

解决方案   $str = str_replace(" ",'',$str);  把 都替换成空格 就ok了

 




姓 名: *
邮 箱:
内 容: *
验证码: 点击刷新 *   

回到顶部