久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php獲取遠(yuǎn)程文件方法有哪些

      方法:1、使用“file_get_contents($url)”語句獲??;2、開啟curl,使用curl_init()、curl_setopt()等函數(shù)獲??;3、使用“fread(fopen("$url","rb"),8192)”語句獲取。

      php獲取遠(yuǎn)程文件方法有哪些

      本教程操作環(huán)境:windows7系統(tǒng)、PHP7.1版,DELL G3電腦

      1.file_get_contents

      $url = 'http://www.xxx.com/'; $contents = file_get_contents($url); //如果出現(xiàn)中文亂碼使用下面代碼 //$getcontent = iconv(“gb2312″, “utf-8″,file_get_contents($url)); //echo $getcontent; echo $contents; ?>

      2.curl

      url = “http://www.xxx.com/”; $ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);//在需要用戶檢測的網(wǎng)頁里需要增加下面兩行 //curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); //curl_setopt($ch, CURLOPT_USERPWD, US_NAME.”:”.US_PWD); $contents = curl_exec($ch); curl_close($ch); echo $contents;

      3.fopen->fread->fclose

      $handle = fopen (“http://www.xxx.com/”, “rb”); $contents = “”; do { $data = fread($handle, 8192); if (strlen($data) == 0) {break;} $contents .= $data; } while(true); fclose ($handle); echo $contents;

      file_get_contents、fopen、curl區(qū)別分析:

      1、使用file_get_contentsfopen必須空間開啟allow_url_fopen。

      方法:編輯php.ini,設(shè) allow_url_fopen = On,allow_url_fopen關(guān)閉時fopenfile_get_contents都不能打開遠(yuǎn)程文件。

      2、使用curl必須空間開啟curl。

      方法:WIN下修改php.ini,將extension=php_curl.dll前面的分號去掉,而且需要拷貝ssleay32.dlllibeay32.dllC:WINDOWSsystem32下;

      Linux下要安裝curl擴(kuò)展。

      建議打開URL時使用file_get_contents()方法,可優(yōu)化打開速度

      推薦學(xué)習(xí):《PHP視頻教程》

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號