-6

Possible Duplicate:
How do I check for valid (not dead) links programatically using PHP?

I am creating a website with many links to external websites, and these websites may go down.

Is it possible to do something like stress tests once in a while to see if they are "still there" ?

Community
  • 1
  • 1
coiso
  • 7,151
  • 12
  • 44
  • 63

1 Answers1

3

This might do

function checkLink($link){ 
    flush(); 
    $fp = @fopen($link, "r"); 
    @fclose($fp); 
    if (!$fp){ 
        return "link is not active"; 
    }else{ 
        return "link is active"; 
    } 
} 
sicKo
  • 1,241
  • 1
  • 12
  • 35