0
点赞
收藏
分享

微信扫一扫

解决file_get_contents乱码

yellowone 2022-03-12 阅读 67
php

用file_get_contents返回的数据是乱码

上网找到了问题,成功解决、

而上面那种全部乱码的,就是因为数据被gzip压缩编码过的。解决方法

$data = file_get_contents($url);

使用
iconv("gb2312", "utf-8//IGNORE",$data);
或者
iconv("GBK","UTF-8",$data);
举报

相关推荐

0 条评论