php的file_get_contents和curl差距

  • 内容
  • 评论
  • 相关

1.png                             2.png


php的file_get_contents和curl的差距好大呀,同样通过接口获取数据用file_get_contents函数打开需要两秒,curl不到一秒,差距呀!!



function curl_get_contents($durl){
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $durl);
  curl_setopt($ch, CURLOPT_TIMEOUT, 5);
  curl_setopt($ch, CURLOPT_USERAGENT, _USERAGENT_);
  curl_setopt($ch, CURLOPT_REFERER,_REFERER_);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $r = curl_exec($ch);
  curl_close($ch);
   return $r;
}


用这个函数curl_get_contents代替file_get_contents 



本文标签:

版权声明:若无特殊注明,本文皆为《菜鸟站长》原创,转载请保留文章出处。

本文链接:php的file_get_contents和curl差距 - https://wlphp.com/?post=81

发表评论

电子邮件地址不会被公开。 必填项已用*标注