I am trying to fetch an image using file_get_contents
function but it gives an error. To handle the error I am using try catch block but it does not catch the error and fails.
My code:
try {
$url = 'http://wxdex.ocm/pdd.jpg'; //dummy url
$file_content = file_get_contents($url);
}
catch(Exception $e) {
echo 'Error Caught';
}
Error:
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: No such host is known
Warning: file_get_contents(http://wxdex.ocm/pdd.jpg): failed to open stream: php_network_getaddresses: getaddrinfo failed: No such host is known.
NOTE:: I am able to fetch any other valid image url on remote.