Posted By

xida on 05/23/10


Tagged


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

rhyno
d0ri0
beertigger


check if url exists


 / Published in: PHP
 

  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  

You need to login to post a comment.