PHP Doku:: Informationen über die aktuellen Transfers abrufen - function.curl-multi-info-read.html

Verlauf / Chronik / History: (27) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige DiensteCURLcURL Funktionencurl_multi_info_read

Ein Service von Reinhard Neidl - Webprogrammierung.

cURL Funktionen

<<curl_multi_getcontent

curl_multi_init>>

curl_multi_info_read

(PHP 5)

curl_multi_info_readInformationen über die aktuellen Transfers abrufen

Beschreibung

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

Ruft Informationen oder Nachrichten der einzelnen Transfers ab sofern vorhanden. Dabei kann es sich beispielsweise um Fehlercodes handeln, aber auch schlicht um die Information, daß ein Transfer abgeschlossen ist.

Wiederholte Aufrufe dieser Funktion liefern immer ein neues Ergebnis, bis durch die Rückgabe von FALSE signalisiert wird daß keine weiteren Informationen verfügbar sind. Der Parameter msgs_in_queue enthält die Anzahl der Informationen die nach Aufruf der Funktion verbleiben.

Warnung

Mit dem Aufruf von curl_multi_remove_handle(). werden diese Daten gelöscht.

Parameter-Liste

mh

Ein von curl_multi_init() zurückgegebenes cURL-Multihandle.

msgs_in_queue

Anzahl der verbleibenden Informationen

Rückgabewerte

Gibt im Erfolgfall ein assoziatives Array zurück, andernfalls FALSE.

Inhalt des zurückgegebenen Arrays
Key: Value:
msg Die Konstante CURLMSG_DONE . Andere Rückgabewerte sind derzeit nicht verfügbar.
result Eine der CURLE_*-Konstanten. Wenn kein Fehler auftrat ist das Ergebnis CURLE_OK.
handle Die entsprechende Resource vom Typ curl.

Beispiele

Beispiel #1 Ein curl_multi_info_read()-Beispiel

<?php

$urls 
= array(
   
"http://www.cnn.com/",
   
"http://www.bbc.co.uk/",
   
"http://www.yahoo.com/"
);

$mh curl_multi_init();

foreach (
$urls as $i => $url) {
    
$conn[$i] = curl_init($url);
    
curl_setopt($conn[$i], CURLOPT_RETURNTRANSFER1);
    
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));

?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

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 Beschreibung
5.2.0 msgs_in_queue wurde hinzugefügt.

Siehe auch


Ein BenutzerBeitrag:
- Beiträge aktualisieren...
Nick Smith
28.05.2010 10:41
Just to let others who might be struggling to get it to work, curl_multi_info_read() doesn't work in PHP versions before 5.2.0, and instead returns NULL immediately.



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)