欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php獲取遠(yuǎn)程文件內(nèi)容的函數(shù)

 更新時(shí)間:2015年11月02日 15:47:39   投稿:lijiao  
這篇文章主要介紹了關(guān)于php獲取遠(yuǎn)程文件內(nèi)容的函數(shù)代碼,使用這個(gè)函數(shù)也可以獲取圖片

一個(gè)簡(jiǎn)單的php獲取遠(yuǎn)程文件內(nèi)容的函數(shù)代碼,兼容性強(qiáng)。直接調(diào)用就可以輕松獲取遠(yuǎn)程文件的內(nèi)容,使用這個(gè)函數(shù)也可獲取圖片。代碼如下:

/**

 * 讀遠(yuǎn)程內(nèi)容

 * @return string

 */
function get_url_content($url){

  if(function_exists("curl_init")){

    $ch = curl_init();

    $timeout = 30;

    curl_setopt($ch, CURLOPT_URL, $url);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);

    $file_contents = curl_exec($ch);

    curl_close($ch);

  }else{

    $is_auf=ini_get('allow_url_fopen')?true:false;

    if($is_auf){

      $file_contents = file_get_contents($url);

    }

  }

  return $file_contents;

}

以上就是php獲取遠(yuǎn)程文件內(nèi)容的函數(shù)代碼,希望這篇文章對(duì)大家學(xué)習(xí)php程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論