Skip to content

Commit 4320e8f

Browse files
committed
Fix php-curl-class#559: Add example that sets custom request instance tags.
1 parent 20707b6 commit 4320e8f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
require __DIR__ . '/../vendor/autoload.php';
3+
4+
use \Curl\MultiCurl;
5+
6+
$urls = array(
7+
'tag3' => 'https://httpbin.org/post',
8+
'tag4' => 'https://httpbin.org/get',
9+
'tag5' => 'https://httpbin.org/html',
10+
);
11+
12+
$multi_curl = new MultiCurl();
13+
14+
$multi_curl->success(function ($instance) {
15+
echo 'call to ' . $instance->id . ' with "' . $instance->myTag . '" was successful.' . "\n";
16+
});
17+
$multi_curl->error(function ($instance) {
18+
echo 'call to ' . $instance->id . ' with "' . $instance->myTag . '" was unsuccessful.' . "\n";
19+
});
20+
$multi_curl->complete(function ($instance) {
21+
echo 'call to ' . $instance->id . ' with "' . $instance->myTag . '" completed.' . "\n";
22+
});
23+
24+
foreach ($urls as $tag => $url) {
25+
$instance = $multi_curl->addGet($url);
26+
$instance->myTag = $tag;
27+
}
28+
29+
$multi_curl->start();

0 commit comments

Comments
 (0)