Get domain favicon through Google


/ Published in: PHP
Save to your folder(s)

A simple function to grab the favicon of a domain using Google s2 Converter. I kept it simple just so it could be changed easily work in a number of different situations.


Copy this code and paste it in your HTML
  1. <?php
  2. // Grab the favicon of a domain using Google s2 Converter
  3. // Put this in your php file and then call it like:
  4. // http://yourdomain.com/file.php?url=somedomain.com
  5.  
  6. function getFavicon(){
  7. $linkurl = $_GET['url'];
  8. $linkurl = str_replace("http://",'',$linkurl); // remove protocol from the domain
  9. $imgurl = "http://www.google.com/s2/favicons?domain=" . $linkurl;
  10. echo '<img src="' . $imgurl . '" width="16" height="16" />';
  11. }
  12.  
  13. getFavicon();
  14. ?>

URL: http://snipplr.com/view/8120/google-favicon/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.