PHP报错:Malformed UTF-8 characters, possibly incorrectly encoded
错误如下:
Malformed UTF-8 characters, possibly incorrectly encoded 或中文乱码 (Uncaught InvalidArgumentException: Malformed UTF-8 characters, possibly incorrectly encoded in)
问题: Uncaught InvalidArgumentException: Malformed UTF-8 characters, possibly incorrectly encoded in
是返回的数据有特殊字符,编码转换回来就好了
mb_convert_encoding($value, 'UTF-8', 'UTF-8');
中文乱码可以用以下方法转码
$content = mb_convert_encoding( $result, 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' );
意思就是把UTF-8,GBK,GB2312,BIG5这几种编码统一都转成UTF-8编码格式。
例如我的代码写法如下:
$res = mb_convert_encoding($result, 'UTF-8', 'UTF-8');
来源地址:https://blog.csdn.net/qq_25359841/article/details/124047856