开发者

What does curl_multi_getcontent($ch) return if $ch isn't ready?

What does curl_multi_getcontent($ch) return if $ch isn'开发者_高级运维t ready in PHP?


The answer to the question you asked is

  • If the response has not been received yet, curl_multi_getcontent returns NULL.
  • If the transfer is in progress, curl_multi_getcontent returns the data retrieved so far.


The question you meant to ask, apparently, is this: How do I know when a curl_multi... operation is finished?

The answer is that you don't use curl_multi_getcontent for this. Instead, repeatedly call curl_multi_exec until the second parameter (which is the number of sub-handles still working on its transfer) goes to 0. This blog post, from the comments in the manual, shows some working code. You may also want to look at curl_multi_select, which will block until there's some activity on a connection. This probably leads to fewer cycles wasted making curl_multi_exec calls: See example #1 on the manual page for curl_multi_exec.

If you're using version 5.2.0 or later, you can use curl_multi_info_read to get the status of individual connections instead of waiting for all of them. (manual)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜