mb_detect_encoding($str, array("ASCII",'UTF-8',"GB2312","GBK",'BIG5'))
mb_convert_encoding($str, 'UTF-8', $encode);
对网页进行编码转换,还是乱码
curl获取数据的时候设置添加下面的选项:
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
使用file_get_contents函数需要安装zlib库
$data = file_get_contents("compress.zlib://".$url);