Yngvarr

Generation

generate functionThu, 13 Apr 2023

curl asynchrone pool

$pool = new AsyncPool(); for($i = 0; $i < 10; $i++) { $pool->add(function() { $ch = curl_init(); // set url curl_setopt($ch,CURLOPT_URL, "http://www.google.com"); //return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $output = curl_exec($ch); // close curl resource to free up system resources curl_close($ch); return $output; }); } $result = $pool->execute(); print_r($result);

Questions about programming?Chat with your personal AI assistant