I am working with CURL request in PHP. My code is like below.
// init curl object
$ch = curl_init();
// define options
$option_array = array(
CURLOPT_URL => $api_url,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_HEADER => 0,
CURLOPT_FOLLOWLOCATION => 1,
CURLOPT_VERBOSE => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_FAILONERROR => 1
);
// apply options
curl_setopt_array($ch, $option_array);
// execute request and get response
$response = curl_exec($ch);
if(curl_errno($ch)){
echo 'error:' . curl_error($ch);
} else {
return $response;
}
curl_close($ch);
How to know internet is not available at CURL request in PHP ?
1条答案
按热度按时间kcrjzv8t1#
看着CURL Error List,你将面对
CURLE_COULDNT_CONNECT (7)
。