Posted By


xida on 05/23/10

Tagged


Statistics


Viewed 490 times
Favorited by 0 user(s)

check if url exists


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



Copy this code and paste it in your HTML
  1. function url_exists($url) {
  2. $ch = curl_init($url);
  3.  
  4. curl_setopt($ch,CURLOPT_HEADER,true);
  5. curl_setopt($ch,CURLOPT_POST,false);
  6. curl_setopt($ch,CURLOPT_FAILONERROR,true);
  7. curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
  8. curl_exec($ch);
  9. $curlInfo = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  10.  
  11. curl_close ($ch);
  12.  
  13. if ($curlInfo != 200 && $curlInfo != 302 && $curlInfo != 304) {
  14. return false;
  15. }else{
  16. return true ;
  17. }
  18. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.