Forum Moderators: coopster
$urlbits = parse_url($array['url']);
$favicon = "http://". $urlbits['host'] ."/favicon.ico";
if (!@fclose(@fopen($favicon, "r"))) {
$favicon = "/dev/images/favicondefault.gif";
}
The problem is that the script is incredibly slow as it waits for every single server in the list (typically 15 or so) to respond. If I just go ahead and print the page then the available favicons display as they load but then I can't substitute in a default favicon if one doesn't exist.
So, my question is, is there a better script for what I'm doing or a way to adjust the timeout for my current script so that a slow external server doesn't cause it to hang?
But as previously stated storing favicons on your server is much more stable solution. You could use fread/fwrite for loading/saving the image. You could also use file_get_contents/file_put_contents. But file_put_contents was introduced in php5 only.