Skip to content

Commit a69c8cd

Browse files
committed
fix demo
1 parent 3312f4c commit a69c8cd

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use Hhxsv5\PhpMultiCurl\MultiCurl;
2525
$options = [//The custom the curl options
2626
CURLOPT_TIMEOUT => 10,
2727
CURLOPT_CONNECTTIMEOUT => 5,
28-
CURLOPT_USERAGENT => 'Multi-Curl Client V1.0',
28+
CURLOPT_USERAGENT => 'Multi-Curl Client V1.5.0',
2929
];
3030

3131
$c1 = new Curl($options);
@@ -59,6 +59,7 @@ if ($allSuccess) {
5959
}
6060

6161
//Reuse $mc
62+
$mc->reset();
6263
$c4 = new Curl();
6364
$c4->makeGet($getUrl);
6465
$c5 = new Curl();
@@ -77,7 +78,6 @@ if ($allSuccess) {
7778
```PHP
7879
//Upload file
7980
$postUrl = 'http://localhost/upload.php';//<?php var_dump($_FILES);
80-
8181
$options = [//The custom the curl options
8282
CURLOPT_TIMEOUT => 10,
8383
CURLOPT_CONNECTTIMEOUT => 5,

examples/benchmark.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@
88

99
$mc = new MultiCurl();
1010

11-
for ($i = 0; $i < 1000; ++$i) {
11+
for ($i = 0; $i < 100; ++$i) {
1212
$c4 = new Curl();
1313
$c4->makeGet('http://www.weather.com.cn/data/cityinfo/101270101.html');
1414

1515
$c5 = new Curl();
1616
$c5->makeGet('http://www.weather.com.cn/data/cityinfo/101270401.html');
1717

1818
$mc->addCurls([$c4, $c5]);
19-
$mc->exec();
2019
}
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+
}

examples/example.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
}
4646

4747
//Reuse $mc
48+
$mc->reset();
49+
4850
$c4 = new Curl();
4951
$c4->makeGet($getUrl);
5052

src/MultiCurl.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,15 @@ public function exec(array $options = [])
7676
}
7777
curl_multi_remove_handle($this->handle, $curl->getHandle());
7878
}
79-
$this->curls = [];
8079

8180
return $success;
8281
}
8382

83+
public function reset()
84+
{
85+
$this->curls = [];
86+
}
87+
8488
public function getCurls()
8589
{
8690
return $this->curls;

0 commit comments

Comments
 (0)