I was wondering what is the best way to execute concurrent HTTP requests in PHP? I have a lot of data, and I would prefer to make several queries at once to get all this.
Does anyone know how I can do this? Preferably in the anonymous / callback function mannor ...
Thank,
Tom.
You can use curl_multi , which internally runs several separate requests under one curl handle.
PHP // "" , - ( , script, exec(), ..).
curl_multi() socket_select()
, , json. php . ,
xhttp.open("GET", "gotoChatRoomorNot.php?q=[{"+str+"},{"+user1+"},{"+user2"}]", true);
php , : JSON PHP?
So make a line in json format and send it all via http. I think you can perform the same behavior with xml, but I don't know xml
you can use HttpRequestPool http://www.php.net/manual/de/httprequestpool.construct.php
$multiRequests = array( new HttpRequest('http://www.google.com', HttpRequest::METH_GET), new HttpRequest('http://www.yahoo.com', HttpRequest::METH_GET) new HttpRequest('http://www.bing.com', HttpRequest::METH_GET) ); $pool = new HttpRequestPool(); foreach ($multiRequests as $request) { $pool->attach($request); } $pool->send(); foreach($pool as $request) { echo $request->getResponseBody(); }
Source: https://habr.com/ru/post/1548738/More articles:https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1548733/search-keyword-using-double-quotes-to-get-exact-match-in-elasticsearch&usg=ALkJrhj9OhQLtkY0l3myFRtn76X1q_8z9wHow to choose the "right" constructor for Activator.CreateInstance - c #How to use queryString () in elasticsearch (java API)? - javaRemove phpunit from pears - phpunitHow can I get data from several web services at the same time using PHP? - phpJavascript: prevent mouse cursor from moving the cursor (prevent it from changing) - javascriptРазница между оператором 3-точечного диапазона и оператором с 2 точками в флип-флопе рубине - rubyVLC error compilation for Android - androidHow to enable multiple modules in RSpec? - ruby | fooobar.comSession with Idle timeout - but how to define actions without saving? - c #All Articles