PHP Doku:: Gibt einen String zurück, der den letzten Fehler der aktuellen Session enthält - function.curl-error.html

Verlauf / Chronik / History: (50) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzSonstige DiensteCURLcURL Funktionencurl_error

Ein Service von Reinhard Neidl - Webprogrammierung.

cURL Funktionen

<<curl_errno

curl_exec>>

curl_error

(PHP 4 >= 4.0.3, PHP 5)

curl_errorGibt einen String zurück, der den letzten Fehler der aktuellen Session enthält

Beschreibung

string curl_error ( resource $ch )

Gibt eine Fehlermeldung in Klartext für die letzte cURL-Operation zurück.

Parameter-Liste

ch

Ein von curl_init() zurückgegebenes cURL-Handle.

Rückgabewerte

Gibt die Fehlermeldung oder, falls kein Fehler aufgetreten ist, '' (den leeren String) zurück.

Beispiele

Beispiel #1 curl_error()-Beispiel

<?php
// Eine cURL-Ressource für ein nicht existierendes Ziel erstellen
$ch curl_init('http://404.php.net/');
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);

if(
curl_exec($ch) === false)
{
    echo 
'Curl-Fehler: ' curl_error($ch);
}
else
{
    echo 
'Operation ohne Fehler vollständig ausgeführt';
}

// Ressource schließen
curl_close($ch);
?>

Siehe auch


3 BenutzerBeiträge:
- Beiträge aktualisieren...
mail at erwindoornbos dot nl
20.04.2009 21:23
While working with curl i got the following error: "empty reply from server".

Searching Google gave no solutions. So i just tried to replace the spaces from the url to %20 and it worked!

Hope this helps someone.
paul at paulmcgarry dot com
25.11.2008 2:00
For a 404 response to actually trigger an error as the example seems to be trying to demonstrate the following option should be set:

curl_setopt($ch,CURLOPT_FAILONERROR,true);

As per http://curl.haxx.se/libcurl/c/libcurl-errors.html

CURLE_HTTP_RETURNED_ERROR (22)
This is returned if CURLOPT_FAILONERROR is set TRUE and the HTTP server returns an error code that is >= 400. (This error code was formerly known as CURLE_HTTP_NOT_FOUND.)
noah dot figg at xpertimage dot com
13.03.2008 23:06
The return value for this function is actually an english description of the error, rather than an error number, FYI.



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",...)