国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 建站經驗 > 正文

PHP C、URL 多線程操作代碼實例

2019-11-02 14:56:06
字體:
來源:轉載
供稿:網友

   這篇文章主要介紹了PHP CURL 多線程操作代碼實例,本文直接給出實現代碼,需要的朋友可以參考下

  使用方法:

  ?

1 2 3 $urls = array("http://baidu.com", "http://21andy.com", "http://google.com"); $mp = new MultiHttpRequest($urls); $mp->start();

  ?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 /* * Curl 多線程類 * 使用方法: * ======================== $urls = array("http://baidu.com", "http://dzone.com", "http://google.com"); $mp = new MultiHttpRequest($urls); $mp->start(); * ======================== */ class MultiHttpRequest { public $urls = array(); public $curlopt_header = 1; public $method = "GET";   function __construct($urls = false) { $this->urls = $urls; }   function set_urls($urls) { $this->urls = $urls; return $this; }   function is_return_header($b) { $this->curlopt_header = $b; return $this; }   function set_method($m) { $this->medthod = strtoupper($m); return $this; }   function start() { if(!is_array($this->urls) or count($this->urls) == 0){ return false; } $curl = $text = array(); $handle = curl_multi_init(); foreach($this->urls as $k=>$v){ $curl[$k] = $this->add_handle($handle, $v); }   $this->exec_handle($handle); foreach($this->urls as $k=>$v){ curl_multi_getcontent($curl[$k]); echo $curl[$k]."n"; //$text[$k] = curl_multi_getcontent($curl[$k]); //echo $text[$k], &quo
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 合作市| 天镇县| 炎陵县| 岑巩县| 古交市| 同德县| 招远市| 灌阳县| 驻马店市| 方正县| 肃宁县| 介休市| 承德市| 航空| 会宁县| 赞皇县| 广河县| 贵定县| 威宁| 涪陵区| 苏尼特左旗| 德兴市| 理塘县| 满城县| 巴林左旗| 咸丰县| 郓城县| 武川县| 泽州县| 陆丰市| 吉安市| 陵水| 应用必备| 杭州市| 二连浩特市| 博乐市| 乳源| 聊城市| 麻城市| 海丰县| 韶关市|