国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

php基于curl重寫file_get_contents函數(shù)實例

Original 2016-12-24 09:59:53 370
abstract:本文實例講述了php基于curl重寫file_get_contents函數(shù)。分享給大家供大家參考,具體如下:file_get_contents在連接不上的時候會提示Connection refused,有時候會帶來不便;另外,curl的性能比file_get_contents高,所以用curl重寫file_get_contentsfunction _file_get_contents($

本文實例講述了php基于curl重寫file_get_contents函數(shù)。分享給大家供大家參考,具體如下:

file_get_contents在連接不上的時候會提示Connection refused,有時候會帶來不便;另外,curl的性能比file_get_contents高,所以用curl重寫file_get_contents

function _file_get_contents($s) {
  $ret = "";
  $ch = curl_init($s);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
  curl_setopt($ch, CURLOPT_TIMEOUT, 0);
  $buffer = curl_exec($ch);
  curl_close($ch);
  if ($buffer === false || empty($buffer)) {
    $ret = "";
  } else {
    $ret = $buffer;
  }
  return $ret;
}

更多關于php基于curl重寫file_get_contents函數(shù)實例請關注PHP中文網(wǎng)(www.miracleart.cn)其它文章!   


Release Notes

Popular Entries