$content = I(“contentt”) ,使用json_decode 函数解析时,返回 null。
原因:json_decode要求的字符串比较严格:
- 使用UTF-8编码
- 不能在最后元素有逗号
- 不能使用单引号
- 不能有\r,\t,如果有请替换。
解决办法:
出现这个问题是因为在 json 字符串中反斜杠被转义,只需要用 htmlspecialchars_decode() 函数处理一下 $content 即可:
$content = htmlspecialchars_decode($content);