Menu Home

curl_errno

osbo.com | PHP | Functions | curl_errno

Return the last error number

Syntax

curl_errno ( resource $ch ) : int

Parameters

ch

A cURL handle returned by curl_init().

Return

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

Examples

1

<?

$ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, "https://nonexistent.osbo.com/");
    
    curl_exec($ch);

    $return = curl_errno($ch);

    echo $return;

curl_close($ch);

?>
6

2

<?

$ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, "https://nonexistent.osbo.com/");
    
    curl_exec($ch);

    if (curl_errno($ch)) {
        echo curl_error($ch);
    }

curl_close($ch);

?>
Could not resolve host: nonexistent.osbo.com

PHP