在PHP中,我使用json_encode()
来回送HTML5数据属性中的array.
<article data-tags='["html5","jquery","php","test's"]'>
正如您所看到的,最后一个标记(test)包含一个引号,使用json_encode()
不带选项会导致解析问题.
So I use json_encode()
with the JSON_HEX_APOS
parameter, and parsing is fine, as my single quotes are encoded, but I wonder: is there a downside doing it like this?