开发者

What do these PHP functions do?

What does this do?

$running = null;
{
  curl_multi_exec($mh,$running);
  usleep(100000);          
} while (开发者_运维技巧$running > 0); 

Also:

curl_setopt($ch, CURLOPT_TIMEOUT, 8); 

Its PHP and curl.


curl_multi_exec is used to process multiple curl handles in parellel. For example, it might be used to download multiple web pages in parallel. This is more efficient than processing the handles in sequence.

The code is kicking of the processing of multiple curl handles. It is checking back every 1/10th of a second to see if all handles have been processed. The second parameter to curl_multi_exec is a flag to say whether the operations are still running. This value is checked to determine whether to keep looping.

The CURLOPT_TIMEOUT setting is used to specify a maximum time to allow a curl handle to process. The code is setting a maximum time of 8 seconds.


So, if I understand what curl_multi_exec does, it seems this code is running the curl multi-handler, $mh every 100000 microseconds (100 milliseconds or 0.1 seconds) to see if it's done.

curl_setopt($ch, CURLOPT_TIMEOUT, 8); tells curl to timeout after 8 seconds.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜