Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP curl_multi_info_read Function

PHP curl_multi_info_read Function

PHP Calendar Reference Manual PHP cURL Reference Manual

(PHP 5)

curl_multi_info_read — Get information about the current transfers of the cURL handles


Description


array curl_multi_info_read ( resource $mh [, int &$msgs_in_queue = NULL ] )

Queries the multi handle for messages or information returned by individual transfers. A message may contain, for example, an error code returned by an individual transfer, or simply a report on whether the transfer has completed.

Calling this function repeatedly returns a new result each time, until there is no more information to return, at which point FALSE is returned as a signal. The integer returned through msgs_in_queue indicates how many messages remain after this call.

Note: The data pointed to by the returned resource will no longer exist after curl_multi_remove_handle() is called.


Parameters

** mh**

A cURL multi handle returned by curl_multi_init().

msgs_in_queue

The number of messages still in the queue.


Return Value

Returns an array of information on success, or FALSE on failure.

Return value contents (contents of the returned array):

Key Value
msg **CURLMSG_DONE** constants. Other return values are currently unavailable.
result **CURLE_*One of the constants. If everything went fine, it will returnCURLE_OK** constant.
handle A cURL resource type indicating the handle it relates to.

Example


 $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 example 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)

Changelog

Version Description
5.2.0 *msgs_in_queue* was added.

PHP Calendar Reference Manual PHP cURL Reference Manual