How to catch curl error in php?

How to catch curl error

Default Asked on July 1, 2019 in PHP.
Add Comment
1 Answer(s)


$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $URL);

curl_setopt($ch, CURLOPT_FAILONERROR, true);

if (curl_errno($ch)) {

$error_msg = curl_error($ch);


if (isset($error_msg)) {

// Handle cURL error as per your need



Team Leader Answered on July 11, 2019.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.