Share icon

Hey, we can see many website have default images if image is broken, so question is how to detect it using php the image is not found given url or not, in php you can do this by just do simple script using cRUL.

cURL is a library that lets you make HTTP requests in PHP, with the script you can check the http request to access different url.

You can use the below code to use this 

ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');

$image_url = ""; // Found
$image_url = ""; // Not Found
$ch = curl_init($image_url);
curl_setopt($ch, CURLOPT_NOBODY, true);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if($httpCode != 404 ){
   echo "Found";
   echo "Not Found";

In above example there are $image_url variable with known and unknown image you can test it by commenting the next one.

hopes this simple script with help you solve the broken image.



Profile picture for user Ronak Kumawat
Anonymous (not verified)
11 May 2022
Thats I am looking for
Profile picture for user Ronak Kumawat
halliemichaelis66 (not verified)
11 May 2022
It's a pity you don't have a donate button! I'd certainly donate to this superb blog! I suppose for now i'll settle for bookmarking and adding your RSS feed to my Google account. I look forward to brand new updates and will share this site with my Facebook group. Talk soon!
Profile picture for user Ronak Kumawat
eulahb25824911… (not verified)
11 May 2022
I wanted to thank you for this wonderful read!! I definitely enjoyed every bit of it. I have you bookmarked to check out new stuff you post…
Profile picture for user Ronak Kumawat
zoracallahan32956 (not verified)
11 May 2022
Do you have a spam problem on this blog; I also am a blogger, and I was wondering your situation; many of us have created some nice methods and we are looking to trade strategies with other folks, why not shoot me an email if interested.
Profile picture for user Ronak Kumawat
ntccecile9795214663 (not verified)
11 May 2022
Your style is so unique in comparison to other folks I have read stuff from. I appreciate you for posting when you've got the opportunity, Guess I'll just book mark this site.
Profile picture for user Ronak Kumawat
francesca23118747 (not verified)
11 May 2022
Appreciating the time and energy you put into your blog and in depth information you present. It's good to come across a blog every once in a while that isn't the same old rehashed material. Fantastic read! I've saved your site and I'm adding your RSS feeds to my Google account.
Profile picture for user Ronak Kumawat
joeylemay06775999874 (not verified)
11 May 2022
Its not my first time to visit this web page, i am browsing this site dailly and get good information from here every day.
Profile picture for user Ronak Kumawat
tyrone51a81594699 (not verified)
11 May 2022
This design is wicked! You obviously know how to keep a reader entertained. Between your wit and your videos, I was almost moved to start my own blog (well, almost...HaHa!) Great job. I really loved what you had to say, and more than that, how you presented it. Too cool!
Profile picture for user Ronak Kumawat
petraditter4899100 (not verified)
11 May 2022
I am actually thankful to the holder of this web site who has shared this enormous piece of writing at here.

Add new comment

Restricted HTML