跳至主要內容
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?

4563博客

全新的繁體中文 WordPress 網站
  • 首頁
  • 求助php 的问题
未分類
14 3 月 2020

求助php 的问题

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
–< 我想成为一个温柔的人,因为曾被温柔的人那样对待,深深了解那种被温柔相待的感觉。——《夏目友人帐》 >–

文章導覽

上一篇文章
下一篇文章

AD

其他操作

  • 登入
  • 訂閱網站內容的資訊提供
  • 訂閱留言的資訊提供
  • WordPress.org 台灣繁體中文

51la

4563博客

全新的繁體中文 WordPress 網站
返回頂端
本站採用 WordPress 建置 | 佈景主題採用 GretaThemes 所設計的 Memory
4563博客
  • Hostloc 空間訪問刷分
  • 售賣場
  • 廣告位
  • 賣站?
在這裡新增小工具