How to make php-curl not return the page if this page has an error. For example: curl performs requests to the php page, everything is OK, but after a while the domain will stop working and curl will return the page with an error, how to make it filt these error pages and if there are errors, it does not return anything
$ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_HEADER => 0, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_AUTOREFERER => 1, CURLOPT_URL => $url, CURLOPT_POST => 1, CURLOPT_CONNECTTIMEOUT => 120, CURLOPT_TIMEOUT => 120, CURLOPT_POSTFIELDS => $data )); $response = curl_exec($ch); if(!$response){ echo 'Error: ' . curl_error($ch) . ' - Code: ' . curl_errno($ch) . "in $url"; }else{ echo $response; }
curl_info(). In general, I would advise using guzzle for work. Everything is already there - ArchDemon