How to Know the URL having the valid image in PHP

This post is about how to check the URL having valid image or not. Here you can seen i have given two method with examples. Suppose the URL contain Image file name but image not there in server, by using this method we can check any webpage to avoid bank image or we can place the default image if our requirement for development.



In first method we have one built in function in PHP named as getimagesize().
Bu using this function we can check whether the image is valid or fake image file.

In second method is done by curling the link or CURL, we can achieve this. Check the below examples. Hope it will help you.
First Method:

Second Method:

 



Tags: ,