js 传参数是使用:encodeURIComponent(JSON2.stringify(param)
在php端处理时直接接收得到的是已经把特殊字符给转义了:{"status":1,"p":1}这个数据直接 json_decode 后得到的数据为空。
解决办法:
htmlspecialchars_decode($str)
string htmlspecialchars_decode ( string $string
[, int $flags
= ENT_COMPAT | ENT_HTML401 ] )
This function is the opposite of htmlspecialchars(). It converts special HTML entities back to characters.
The converted entities are: &, " (when ENT_NOQUOTES
is not set), ' (when ENT_QUOTES
is set), < and >.
实例:
$str = ”<p>this -> "</p>\n”;
echo htmlspecialchars_decode($str); //输出: <p>this -> “</p>
echo htmlspecialchars_decode($str, ENT_NOQUOTES); //<p>this -> "</p>