I am working on a PHP web application, and I need to perform some network operations in the request, for example, selecting someone from a remote server based on a user request.
Is it possible to simulate asynchronous behavior in PHP, given that I need to pass some data to the function, as well as get output from it.
My code is similar:
<?php $data1 = processGETandPOST(); $data2 = processGETandPOST(); $data3 = processGETandPOST(); $response1 = makeNetworkCall($data1); $response2 = makeNetworkCall($data2); $response3 = makeNetworkCall($data3); processNetworkResponse($response1); processNetworkResponse($response2); processNetworkResponse($response3); exit; ?>
Each network operation takes about 5 seconds to complete adding a total of 15 seconds to the response time of my application if I make 3 requests.
The makeNetworkCall () function performs an HTTP POST request.
The remote server is a third-party API, so I can not control it.
PS: Please do not respond to offers about AJAX or other things. I am currently looking to see if I can do this through PHP, maybe with a C ++ extension or something like that.
asynchronous php network-programming
Hardeep Singh Jan 09 '13 at 13:27 2013-01-09 13:27
source share