PHP接收前端ajax提交的json使用json_decode出现无法解析json的情况
前几天跟公司前端对接接口的时候 , 前端传入的json参数后台无法解析 .
后来分析了一下之后 , 发现json字符串之中的部分特殊字符被html转义了
解决方法 : 使用 html_entity_decode() 函数
$json = $_POST['json'];
$json = html_entity_decode($json); //**
$arr = json_decode($json);
html_entity_decode() 函数把 HTML 实体转换为字符 , 这样就可以完美解决以上发现的问题