Asynchronous & multi threading in php [duplicate]
Possible Duplicate:
Threads in PHP.
I m getting a list of 20 urls. I need to process some operation on these request simultaneously.
and my php execution will continue only after all request is over.
example
<?php
for($i=0;$i<120;$i++)
{
//parallel processing of 20 urls
}
com开发者_高级运维e here only if all request are fullfilled
There is no inherent multi threading in php.
Instead what you could do is invoke 20 php-cli calls which don't return anything to the caller. :)
(Thats bullish, but if there is lot of things to process, then it might be worth. Depends on your situation though)
You could also see this thread.
Someone else might come up with a better answer as well...
Edit:
Oh, and btw, if you were going to call those URLs, use @symcbean's answer, about curl_multi_exec I didn't think in that angle at all :p
See the curl_multi_ functions
There is a way to perform multiple simultaneous requests using the cURL library. Have a look at the curl_multi_
functions.
精彩评论