Reputation: 40167
I'm trying to debug this cURL
-operation. The var_dump()
is returning bool(false)
How can I make it exit the try in that case?
function parse($url, $headonly = TRUE ){
$agents = 'Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16';
try
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_USERAGENT, $agents);
curl_setopt($ch, CURLOPT_URL, $url);
$curlResp = curl_exec($ch);
curl_close($ch);
var_dump($curlResp); //RETURNS bool(false)
die;
$resp = str_replace("class=l","class='l'",$curlResp);
return $resp;
}
catch( Exception $e)
{
$strResponse = "";
$strErrorCode = $e->getCode();
$strErrorMessage = $e->getMessage();
print_r($arrCurlInfo, $strErrorCode, $strErrorMessage);
die;
} //end catch
}
Upvotes: 1
Views: 13847
Reputation: 208
Why not try throwing an Exception when false is returned?
i.e.
if ($curlResp === FALSE) {
throw new Exception();
}
Upvotes: 4