脚本宝典收集整理的这篇文章主要介绍了限制传出PHP卷曲请求,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
(您可以使用this library以OOP方式进行)
例如:
@H_304_15@// Creates the curl multi handle $mh = curl_multi_inIT(); $handles = array(); foreach($urls as $url) { // Create a new single curl handle $ch = curl_init(); // Set options curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_HEADER,0); curl_setopt($ch,CURLOPT_RETURNtransfer,true); curl_setopt($ch,CURLOPT_TIMEOUT,300); // Add to the multi handle curl_multi_add_handle($mh,$ch); // Put the handles in an array to loop this later on $handles[] = $ch; } // Execute the multi handle $running=null; do { $mrc = curl_multi_exec($mh,$running); // Added a usleep for 0.50 seconds to reduce load usleep (250000); } while($running > 0); // Get the content of the urls (if there is any) $output = array(); for($i=0; $i<count($handles); $i++) { // Get the content of the handle $content = curl_multi_getcontent($handles[$i]); $output[] = $content; if($PRintOutput) { echo $content; } // Remove the handle From the multi handle curl_multi_remove_handle($mh,$handles[$i]); } // close the multi curl handle to free system resources curl_multi_close($mh);
以上是脚本宝典为你收集整理的限制传出PHP卷曲请求全部内容,希望文章能够帮你解决限制传出PHP卷曲请求所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。