What is the callback function in PHPcURL concurrency?

Source: Internet
Author: User
What is the callback function in PHPcURL concurrency? Curl cURL php concurrency curlcURL php concurrency curl cURL concurrency

function rolling_curl($urls, $delay) {    $queue = curl_multi_init();    $map = array();     foreach ($urls as $url) {        $ch = curl_init();         curl_setopt($ch, CURLOPT_URL, $url);        curl_setopt($ch, CURLOPT_TIMEOUT, 1);        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);        curl_setopt($ch, CURLOPT_HEADER, 0);        curl_setopt($ch, CURLOPT_NOSIGNAL, true);         curl_multi_add_handle($queue, $ch);        $map[(string) $ch] = $url;    }     $responses = array();    do {        while (($code = curl_multi_exec($queue, $active)) == CURLM_CALL_MULTI_PERFORM) ;         if ($code != CURLM_OK) { break; }         // a request was just completed -- find out which one        while ($done = curl_multi_info_read($queue)) {             // get the info and content returned on the request            $info = curl_getinfo($done['handle']);            $error = curl_error($done['handle']);            $results = callback(curl_multi_getcontent($done['handle']), $delay);            $responses[$map[(string) $done['handle']]] = compact('info', 'error', 'results');             // remove the curl handle that just completed            curl_multi_remove_handle($queue, $done['handle']);            curl_close($done['handle']);        }         // Block for data in / output; error handling is done by curl_multi_exec        if ($active > 0) {            curl_multi_select($queue, 0.5);        }     } while ($active);     curl_multi_close($queue);    return $responses;}


That is, what is the function of row 30th?
Curl_multi_getcontent ($ done ['handle']) I know, what is the role of the following parameter?


Reply to discussion (solution)

Do you know the definition of the custom function callback?
$ Delay is passed in and passed to callback. of course, only you know the meaning.

Well, check what the code of the callback function is written. if you cannot understand it, you can send it.

Do you know the definition of the custom function callback?
$ Delay is passed in and passed to callback. of course, only you know the meaning.

Well, check what the code of the callback function is written. if you cannot understand it, you can send it.

Found... It turned out to be... testing performance...

function callback($data, $delay) {    preg_match_all('/(.+)<\/h3>/iU', $data, $matches);    usleep($delay);    return compact('data', 'matches');}


Alas... This is caused by incomplete reading of articles...
Thank you for your attention ~~~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.