/ Published in: PHP
**Example of use:**
<a href="http://www.php.net/manual/en/index.php"><img src="<?php echo get_favicon('http://www.php.net/manual/en/index.php') ?>" alt="Favicon" title="See PHP documentation" width="16" height="16" /></a>
<a href="http://www.php.net/manual/en/index.php"><img src="<?php echo get_favicon('http://www.php.net/manual/en/index.php') ?>" alt="Favicon" title="See PHP documentation" width="16" height="16" /></a>
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * Get favicon from a URL. * * @author Pierre-Henry Soria <[email protected]> * @copyright (c) 2013, Pierre-Henry Soria. All Rights Reserved. * @param string $sUrl * @return string The favicon image. */ function get_favicon($sUrl) { $sApiUrl = 'http://www.google.com/s2/favicons?domain='; $sDomainName = get_domain($sUrl); return $sApiUrl . $sDomainName; } /** * Get domain name from a URL (helper function). * * @author Pierre-Henry Soria <[email protected]> * @copyright (c) 2013, Pierre-Henry Soria. All Rights Reserved. * @param string $sUrl * @return string $sUrl Returns the URL to lower case and without the www. if present in the URL. */ function get_domain($sUrl) { return $sHost; }