I'm trying to check 2 things with a string of text. First I want to check if it's a real URL. Then, if it is, I want to check if that URL is an image. I came upon this answer, and it said to do the following:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$imageURL);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if(curl_exec($ch)!==FALSE) {
print_r("went Throught");
}
else {
print_r("Failed");
}
curl_close($ch);
No matter what $imageURL
is, I always get Failed
. How can I achieve the following:
if ($imageURL isRealUrl) {
// Do some code
if ($imageURL isInArrayOfImages(.png, .jpg, .GIF) {
// Do something
}
}