PHP

MULTIPLE ASYNC CURL IN PHP

INITIALIZE CURL $chA = curl_init(); $chB = curl_init();

SET OPTIONS curl_setopt($chA, CURLOPT_URL, "http://site-A.com"); curl_setopt($chB, CURLOPT_URL, "http://site-B.com"); curl_setopt($chA, CURLOPT_RETURNTRANSFER, true); curl_setopt($chB, CURLOPT_RETURNTRANSFER, true);

CURL INITILIZE

01

INITIALIZE MULTI-CURL $mh = curl_multi_init(); curl_multi_add_handle($mh, $chA); curl_multi_add_handle($mh, $chB); 

RUN MULTI-CURL do { curl_multi_exec($mh, $active); } while ($active);

MULTIPLE CURL RUN

02

CLOSE WHEN DONE curl_multi_remove_handle($mh, $chA); curl_multi_remove_handle($mh, $chB); curl_multi_close($mh);

FETCH RESULTS $resA = curl_multi_getcontent($chA); $resB = curl_multi_getcontent($chB);

CURL GET RESULTS

03