gnocuil 大佬有话说 :
求助php 的问题
我的目的是想用下面这段php代码实现访问某个编码为utf-8的网站,有没办法把这个utf-8的网站转换为gbk编码正常输出
<?php
$url =$_GET[‘u’];
echo $cont1 =get_url($url);
function get_url($url,$host = null){
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
//curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
//curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
//curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)");
//curl_setopt($curl, CURLOPT_FOLLOWLOCATION, $location);
//curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
//curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
//curl_setopt($curl, CURLOPT_ENCODING, "gzip" );
//curl_setopt($curl, CURLOPT_HTTPGET, 1);
//curl_setopt($curl, CURLOPT_COOKIE, $this->cookies);
//curl_setopt($curl, CURLOPT_COOKIEJAR, ‘cookie.txt’);
//curl_setopt($curl, CURLOPT_COOKIEFILE, ‘cookie.txt’);
curl_setopt($curl, CURLOPT_TIMEOUT, 30);
//curl_setopt($curl, CURLOPT_HEADER, 1);
//curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$tmpInfo = curl_exec($curl);
if (curl_errno($curl)) {
echo’Curl error: ‘.curl_error ($curl);exit();
}
curl_close($curl);
return $tmpInfo;
}
?>
kydtf 大佬有话说 :
楼下解决:lol
inkedus 大佬有话说 :
:lol
–< 我想成为一个温柔的人,因为曾被温柔的人那样对待,深深了解那种被温柔相待的感觉。——《夏目友人帐》 >–