(PHP 5)
curl_multi_info_read — Get relevant transfer information for the currently parsed cURL
array curl_multi_info_read ( resource $mh [, int &$msgs_in_queue = NULL ] )
Query the batch handle to see if there are messages or information returned in the separate transmission thread. Messages may contain reports such as error codes returned from individual transfer threads or simply whether the transfer thread has completed.
This function is called repeatedly, and it returns a new result each time, until no more information is returned, and FALSE is returned as a signal. The integer returned by msgs_in_queue indicates that it will contain the number of messages remaining after this function is called.
Note: The data pointed to by the returned resource will not exist after calling curl_multi_remove_handle().
mh
cURL multiple handles returned by curl_multi_init().
msgs_in_queue
The number of messages still in the queue.
Returns an array of relevant information on success, and returns FALSE on failure.
Return value content (return the contents of the array):
key | value |
---|---|
msg | CURLMSG_DONE constant. Other return values are currently unavailable. |
result | One of the CURLE_* constants. If there is no problem with all operations, the CURLE_OK constant will be returned. |
handle | The cURL resource type indicates the handle it relates to. |
<?php$urls = array( "http://www.baidu.com/", "http://www.google.com.hk/", "http://www.w3cschool.cc/"); $mh = curl_multi_init();foreach ($urls as $i => $url) { $conn[$i] = curl_init($url); curl_setopt($conn[$i], CURLOPT_RETURNTRANSFER, 1); curl_multi_add_handle($mh, $conn[$i]);}do { $status = curl_multi_exec($mh, $active); $info = curl_multi_info_read($mh); if (false !== $info ) { var_dump($info); }} while ($status === CURLM_CALL_MULTI_PERFORM || $active);foreach ($urls as $i => $url) { $res[$i] = curl_multi_getcontent($conn[$i]); curl_close($conn[$i]);}var_dump( curl_multi_info_read($mh));?>
The output of the above routine is similar to:
array(3) { ["msg"]=> int(1) ["result"]=> int(0) ["handle"]=> resource(5) of type (curl)}array(3) { [ "msg"]=> int(1) ["result"]=> int(0) ["handle"]=> resource(7) of type (curl)}array(3) { ["msg"]=> int(1) ["result"]=> int(0) ["handle"]=> resource(6) of type (curl)}bool(false)
Version | illustrate |
---|---|
5.2.0 | msgs_in_queue is added. |