$mubiao = "http://www.tugaga.com";
// 发起HTTP请求获取源码
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $mubiao);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$code = curl_exec($ch);
curl_close($ch);
$code 就是网页源代码(目标站是什么编码读取出来就是什么编码)
$lujing = "123.txt";
file_put_contents($lujing,$code );
再也不用为转换编码而麻烦了
如果有特殊需求 需要强制转换编码;
$encode = mb_detect_encoding($neirong, array("ASCII",'UTF-8',"GB2312","GBK",'BIG5','LATIN1'));