今天在线上使用了
1
|
json_encode(htmlentities(
$value
))
|
发现出现了!
1
|
[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之前的
1
|
htmlentities(string,quotestyle,character-set)
|
其中character-set=SO-8859-1。
如果里面有中文的话就就乱码了不能转义了,json_encode只认UTF-8.导致出现报错。
改为
1
|
htmlentities(
$instance
,ENT_QUOTES ,
'UTF-8'
)
|
解决
本文转自 梦朝思夕 51CTO博客,原文链接:http://blog.51cto.com/qiangmzsx/1670507