Simple code, of course works fine $fp = @fopen($url,"r") or exit(); But, I need more. Having searched here and web-wide, can't find a good answer, tried a few, no luck. I am wanting to time-out (a simple exit() or die() will suffice) if the $url (or contents) is unreachable. It's got me stumped.
I normally do it with a local cache.. that way you can use your cache if the file is unreachable.. $filename = "/home/public_html/cache/filecache.inc.php"; $remotefile = "http://www.remotesite.com/remotefile.html"; if (rand(0,20)==1) { if($newdata = @file_get_contents($remotefile)) { $filepointer = fopen($filename, "w"); fputs ($filepointer,$newdata); fclose ($filepointer); } } $finalvariable = file_get_contents($filename); PHP: