I'm wondering what would make this code falsely fail. It returns false result when passing certain Image URLs. I don't have control of what the URL is, but I can encode it somehow to make this work?
I assume the problem lays with the space located in the Image URL. How to avoid this?
function checkRemoteFile($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
// don't download content
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
return (curl_exec($ch)!==FALSE);
}