Learn to get and render favicon.ico files dynamically from other servers in your PHP scripts. You can look for files and also process the DOM structure of external pages on the web. I recommend saving the favicon image file to your server converting it to a JPG or PNG file if it will be a frequently viewed image.
# USAGE EXAMPLE
<?php /* Online PHP Examples with Source Code website: http://4evertutorials.blogspot.in/ */ function getfavicon($url){ $favicon = ''; $html = file_get_contents($url); $dom = new DOMDocument(); $dom->loadHTML($html); $links = $dom->getElementsByTagName('link'); for ($i = 0; $i < $links->length; $i++){ $link = $links->item($i); if($link->getAttribute('rel') == 'icon'){ $favicon = $link->getAttribute('href'); } } return $favicon; } $website = "http://4evertutorials.blogspot.com/"; # replace with your url $favicon = getfavicon($website); echo $favicon; ?>
0 comments:
Post a Comment