less than 1 minute read

I was after a php function that would get the favicon for a supplied domain, I did attempt to write my own but it proved more complex than I had first anticipated. Never fear, I did a quick google and came across a couple of sites.

I tried this code, but it returned nothing. I attempted to fix it, but it still didn’t really perform very well.

This was interesting, it seems that google has an API for returning favicons…

function get_favicon($host) { return ‘http://www.google.com/s2/favicons?domain=’.$host; }

That was easy. Also, if you don’t fancy using Google (some people don’t) you can try one of these instead:

  • http://duckduckgo.com/i/%s.ico
  • http://getfavicon.appspot.com/%s
  • http://www.getfavicon.org/?url=%s

Where %s is, but the host or domain name.

Comments