跳转到主要内容

curl-errno

curl_errno

Return the last error number

ENTITY

int

curl_errno

CurlHandle

handle

Returns the error number for the last cURL operation.

ENTITY

ENTITY

Returns the error number or 0 (zero) if no error occurred.

[!NOTE] When a CurlHandle is executed via curl_multi_exec, this function returns 0 until curl_multi_info_read has returned the message for that handle. The error code for each individual handle is available as the result key returned by curl_multi_info_read.

ENTITY

ENTITY ENTITY

ENTITY

curl_errno example

<?php
// Create a curl handle to a non-existing location
$ch = curl_init('http://404.php.net/');

// Execute
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);

// Check if any error occurred
if(curl_errno($ch))
{
    echo 'Curl error: ' . curl_error($ch);
}
?>

    

ENTITY

curl_error, curl_multi_info_read, Curl error codes