Hi Gabon
You've got the right idea. Try this:
<?php
$failfile = "dud_urls.txt";
$website = "http://www.mywebsite.com/index.html";
$fp = fopen($website,"r");
$count = fgets($fp,1024);
fclose($fp);
if($count>0){
echo "File Exists";
}else{
$handle = fopen($failfile, "a");
fwrite($handle, $website);
fclose($handle);
}
?>
Of course, what you really want to do is create an array of URLs and get your code to iterate through the array, doing a check on each item. In fact, what you really, really want to do is have all the URLs in a DB table, extract the URLs as an array and then get the code to run through it. You then want to re-insert the dud URLs into another table in the DB and decide what you're going to do with them. Either that or write them to an XML file which you parse as HTML and then click on by hand. The possibilities are endless. If you do this stuff, you're well on your way to having created a PHP link checker which you can submit to Hotscripts or something.
HTH
Norm