swoole(v4.4.16) 协程 curl

2021-01-15  本文已影响0人  vins
Swoole\Runtime::enableCoroutine(true, SWOOLE_HOOK_ALL | SWOOLE_HOOK_CURL);
    for ($i = 0; $i <= 20; $i++) {
        go(function () use ($i){
           //   sleep(2);
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, 'http://116.62.45.127/index.php?a='.$i);
            curl_setopt($ch, CURLOPT_HEADER,0);
            curl_exec($ch);
            curl_close($ch);
        });
    };
上一篇下一篇

猜你喜欢

热点阅读