PHP 抓取远程文件出错的解决方案

时间:2015-06-23 19:29:26   收藏:0   阅读:202

file_get_contents在某些情况下会出错。
这样在运行中会时不时的出现上述错误,我也换过file_get_contents等其他函数都没用,在网上查阅后发现用CURL方法抓取不会出错

$url = "http://www.php100.com/logo.gif";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT,10);
$img = curl_exec($ch);

原文:http://www.cnblogs.com/prolovecui/p/4595915.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!