How to catch curl execution error

Few days before, I was sending curl execution request for posting data, But I was unable to get the curl response and even error also. I tried Google and found some trips to check the error occurring on executing curl request.

Steps are as follows :
1. Place this code before executing curl (curl_exe) :

$chSt- cURL handle returned by curl_init()

2. If we want to know the Http status code then place this statement after curl_exec :

3. If we want to get the Error No. then use this statement after curl_exec :

4. If we want to get Error message, use curl_error() :

This function Returns the error message or ” (the empty string) if no error occurred.
but we need to set following option before curl_exec() :

Curl errors are as follows :

This post would be useful for the developers like me. If anyone found this information useful, Please like it and if you need support regarding curl execution or error, just drop a comment below.

Like this Post? Share