-
Notifications
You must be signed in to change notification settings - Fork 820
Closed
Description
Hi
I spent a few hours today looking for a bug in my application. It turned out that the error was in the class. It appears when we want to use multicurl and tags, and the tag is passed to the instance and we name it "id". If we name it differently, everything works fine. Below is an example that uses a multicurl to load three pages, and save it to file, two of them, are identical. When we use $instance>pid instead of $instance->id, everything works fine.
Code:
<?php
require __DIR__ . './vendor/autoload.php';
use Curl\MultiCurl;
$urls = [
1 => 'https://www.spotify.com/pl/',
2 => 'https://www.spotify.com/gr/',
3 => 'https://www.spotify.com/be-fr/',
];
$multi_curl = new MultiCurl();
$multi_curl->complete(function ($instance) {
// if I use $instance->pid all working fine
file_put_contents($instance->id.".html", $instance->response);
});
foreach ($urls as $tag => $url) {
$instance = $multi_curl->addGet($url);
// if I use $instance->pid = $tag all working fine
$instance->id = $tag;
}
$multi_curl->start();
Metadata
Metadata
Assignees
Labels
No labels