laravle框架报错Malformed UTF-8 characters, possibly incorrectly encoded
原因使用了redis, 没有配置
问题
- PHP无法转json
- Malformed UTF-8 characters, possibly incorrectly encoded {"exception":"[object] (InvalidArgumentException(code: 0): Malformed UTF-8 characters, possibly incorrectly encoded at C:\phpstudy_pro\WWW\php8.club\vendor\laravel\framework\src\Illuminate\Http\JsonResponse.php:75)
- Laravel中使用response()方法调用json()返回数据unicode编码转换的问题
根本问题
json_encode 要求 value 是utf-8 (点击查看手册)
解决办法
1.数据库配置问题
2.substr() 截取中文,导致乱码,建议试用mb_substr()
3.mb_convert_encoding 转下编码。mb_convert_encoding( $string, 'UTF-8', 'UTF-8,GBK,GB2312,BIG5' ) 点击查看手册