curl - How to merge result of 2 PHP script outputs -


i getting result first script. want response both php scripts in 1 output. in program developing, querying several remote servers. have search information on different servers , return result in 1 response.

<?php     // build individual requests above, not execute them     $ch_1 = curl_init('http://lifesaver.netai.net/example/pharm.php');     $ch_2 = curl_init('http://192.168.1.2/example/pharm.php');     curl_setopt($ch_1, curlopt_returntransfer, false);     curl_setopt($ch_2, curlopt_returntransfer, false);     curl_setopt($ch_1, curlopt_post,1);     curl_setopt($ch_2, curlopt_post,1);     curl_setopt($ch_1, curlopt_postfields, "name=$value");     curl_setopt($ch_2, curlopt_postfields, "name=$value");      // $_post["name"]      // build multi-curl handle, adding both $ch     $mh = curl_multi_init();     curl_multi_add_handle($mh, $ch_1);     curl_multi_add_handle($mh, $ch_2);      // execute queries simultaneously, , continue when complete     $running = null;     {       curl_multi_exec($mh, $running);     } while ($running);      // of our requests done, can access results     $response_1 = curl_multi_getcontent($ch_1);     $response_2 = curl_multi_getcontent($ch_2);      echo $response_1;     echo $response_2; ?> 

according documentation of curl_multi_getcontent, need set curlopt_returntransfer true instead of false.

also, documentation of curl_multi_init shows example different yours when comes execution loop:

//execute handles $running = null; {     $mrc = curl_multi_exec($mh, $running); } while ($mrc == curlm_call_multi_perform);  while ($running && $mrc == curlm_ok) {     if (curl_multi_select($mh) != -1) {         {             $mrc = curl_multi_exec($mh, $running);         } while ($mrc == curlm_call_multi_perform);     } } 

you try way.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -