I\'m trying to set an API with a payment processor. Below is the code they provided me. There are some information in the $result variable that I want, what I don\'t underst
From the manual:
Returns TRUE on success or FALSE on failure. However, if the CURLOPT_RETURNTRANSFER option is set, it will return the result on success, FALSE on failure.
Your code already contains this line (which is good):
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
The 1
means you will receive an explanatory result back from $result = curl_exec ($ch)
instead of just true
or false
.
Your error checking code could therefore look like:
$result = curl_exec ($ch);
if($result === FALSE) {
die(curl_error($ch));
}
You can also check they type of variable returned via var_dump: var_dump($result)
.