I found this nifty way to check if a page really exists:
$headers=@get_headers($imageurl);
if(strpos($headers[0],'200')===false){
echo "not valid";
exit;
}
What I need to achieve, though, is to check whether on that page is really only an image.
For example, when you try the following link:
http://www.google.com/image.jpg
it will return 200 because Google has it’s own error page – however, it should be possible to find out not only that there is no image on that page, but also that an image is not the only thing on that page, even when there is other content (like here: http://www.kapstadt-entdecken.de/wp-content/gallery/robben-island/1robben-island.jpg).
How I can I achieve that?
Thanks a lot!
Dennis
You will probably want to use HEAD requests when getting headers (it doesn’t do that by default):
Second, you can pass a second parameter to
get_headersto parse it for you:Then, you can check the rest as per normal: