今天線上上使用了
json_encode(htmlentities($value))
發現出現了!
[03-Jul-2015 02:52:44 UTC] PHP Warning: json_encode_plus() [<a href='function.json-encode-plus'>function.json-encode-plus</a>]: Invalid UTF-8 sequence in argument in /home/users/ouerqiang/fbiz/framework/BizBootstrap.php on line 106
乍一看,不知道出現了什麼問題,經過看來資料發現PHP 5.4之前的
htmlentities(string,quotestyle,character-set)
其中character-set=SO-8859-1。
如果裡面有中文的話就就亂碼了不能轉義了,json_encode隻認UTF-8.導緻出現報錯。
改為
htmlentities($instance,ENT_QUOTES ,'UTF-8')