File tree Expand file tree Collapse file tree 4 files changed +15
-6
lines changed Expand file tree Collapse file tree 4 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ use Hhxsv5\PhpMultiCurl\MultiCurl;
25
25
$options = [//The custom the curl options
26
26
CURLOPT_TIMEOUT => 10,
27
27
CURLOPT_CONNECTTIMEOUT => 5,
28
- CURLOPT_USERAGENT => 'Multi-Curl Client V1.0',
28
+ CURLOPT_USERAGENT => 'Multi-Curl Client V1.5. 0',
29
29
];
30
30
31
31
$c1 = new Curl($options);
@@ -59,6 +59,7 @@ if ($allSuccess) {
59
59
}
60
60
61
61
//Reuse $mc
62
+ $mc->reset();
62
63
$c4 = new Curl();
63
64
$c4->makeGet($getUrl);
64
65
$c5 = new Curl();
@@ -77,7 +78,6 @@ if ($allSuccess) {
77
78
``` PHP
78
79
//Upload file
79
80
$postUrl = 'http://localhost/upload.php';//<?php var_dump($_FILES);
80
-
81
81
$options = [//The custom the curl options
82
82
CURLOPT_TIMEOUT => 10,
83
83
CURLOPT_CONNECTTIMEOUT => 5,
Original file line number Diff line number Diff line change 8
8
9
9
$ mc = new MultiCurl ();
10
10
11
- for ($ i = 0 ; $ i < 1000 ; ++$ i ) {
11
+ for ($ i = 0 ; $ i < 100 ; ++$ i ) {
12
12
$ c4 = new Curl ();
13
13
$ c4 ->makeGet ('http://www.weather.com.cn/data/cityinfo/101270101.html ' );
14
14
15
15
$ c5 = new Curl ();
16
16
$ c5 ->makeGet ('http://www.weather.com.cn/data/cityinfo/101270401.html ' );
17
17
18
18
$ mc ->addCurls ([$ c4 , $ c5 ]);
19
- $ mc ->exec ();
20
19
}
21
- echo microtime (true ) - $ start ;
20
+ $ mc ->exec ();
21
+ echo microtime (true ) - $ start ;
22
+ foreach ($ mc ->getCurls () as $ curl ) {
23
+ var_dump ($ curl ->getResponse ()->getBody ());
24
+ }
Original file line number Diff line number Diff line change 45
45
}
46
46
47
47
//Reuse $mc
48
+ $ mc ->reset ();
49
+
48
50
$ c4 = new Curl ();
49
51
$ c4 ->makeGet ($ getUrl );
50
52
Original file line number Diff line number Diff line change @@ -76,11 +76,15 @@ public function exec(array $options = [])
76
76
}
77
77
curl_multi_remove_handle ($ this ->handle , $ curl ->getHandle ());
78
78
}
79
- $ this ->curls = [];
80
79
81
80
return $ success ;
82
81
}
83
82
83
+ public function reset ()
84
+ {
85
+ $ this ->curls = [];
86
+ }
87
+
84
88
public function getCurls ()
85
89
{
86
90
return $ this ->curls ;
You can’t perform that action at this time.
0 commit comments