Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

curl error handling

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $your_url);
curl_setopt($ch, CURLOPT_FAILONERROR, true); // Required for HTTP error codes to be reported via our call to curl_error($ch)
//...
curl_exec($ch);
if (curl_errno($ch)) {
    $error_msg = curl_error($ch);
}
curl_close($ch);

if (isset($error_msg)) {
    // TODO - Handle cURL error accordingly
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #curl #error #handling
ADD COMMENT
Topic
Name
8+8 =