(PHP 5)
curl_multi_add_handle — Add individual curl handles to a curl batch session
int curl_multi_add_handle ( resource $mh , resource $ch )
Add ch handle to batch session mh
mh
cURL multiple handles returned by curl_multi_init().
ch
The cURL handle returned by curl_init().
Returns 0 on success and one of CURLM_XXX error codes on failure.
This example will create 2 cURL handles, add them to a batch handler, and run them in parallel.
<?php// Create a pair of cURL resources $ch1 = curl_init();$ch2 = curl_init();// Set the URL and corresponding options curl_setopt($ch1, CURLOPT_URL, "http://www.w3cschool.cc/ ");curl_setopt($ch1, CURLOPT_HEADER, 0);curl_setopt($ch2, CURLOPT_URL, "http://www.php.net/");curl_setopt($ch2, CURLOPT_HEADER, 0);//Create batch cURL handle $mh = curl_multi_init();// Add 2 handles curl_multi_add_handle($mh,$ch1);curl_multi_add_handle($mh,$ch2);$running=null;//Execute batch handle do { curl_multi_exec($mh,$running);} while($running > 0);//Close all handles curl_multi_remove_handle($mh, $ch1);curl_multi_remove_handle($mh, $ch2);curl_multi_close($mh);?>