title: Asynchronous Function Call in PHP
body: <p>I am working on an a PHP web application and i need to perform some network operations in the request like fetching someone from remote server based on user's request.</p>
  
  <p>Is it possible to simulate asynchronous behavior in PHP given that i have to pass some data to a function and also need output from it.</p>
  
  <p>My code is like:</p>
  
  <pre><code>&lt;?php
  
       $data1 = processGETandPOST();
       $data2 = processGETandPOST();
       $data3 = processGETandPOST();
  
       $response1 = makeNetworkCall($data1);
       $response2 = makeNetworkCall($data2);
       $response3 = makeNetworkCall($data3);
  
       processNetworkResponse($response1);
       processNetworkResponse($response2);
       processNetworkResponse($response3);
  
       /*HTML and OTHER UI STUFF HERE*/
  
       exit;
  ?&gt;
  </code></pre>
  
  <p>Each network operation takes around 5 seconds to complete adding a total of 15 seconds to the response time of my application given i make 3 requests.</p>
  
  <p>The  makeNetworkCall() function just do a HTTP POST request.</p>
  
  <p>The remote server is an 3rd party API so i don't have any control over there.</p>
  
  <p>PS: Please do not answer giving suggestions about AJAX or Other things. I am currently looking if i can do this through PHP may be with an C++ extension or something like that.</p>