Check to see if a external image exists


/ Published in: PHP
Save to your folder(s)

Simple call imageExists('http://example.com/image.jpg');
true if it exists else false.


Copy this code and paste it in your HTML
  1. function imageExists($url){
  2. $h = get_headers($url);
  3. return ($h[0] == "HTTP/1.1 404 Not Found")?false:true;
  4. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.