PHP5.3 htmlentities与json_encode的坑
今天在线上使用了json_encode(htmlentities($value)) 发现出现了!
PHP Warning:json_encode_plus() : 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')
解决
页:
[1]