There are three functions that I would like to do:
1.) Test to see if there is a favicon in the root directory, and if so, display it.
2.) Report if there is a favicon tag, and if so...
3.) Extract and display the favicon meta tag if it exists.
The first function is not working... I have tried a number of ways and cannot get it to properly report if there is no favicon in the root directory.
Here is the code:
PHP Code:
<form action="faviconcheck.php" method="post">
<input type="text" name="url" value="http://www.metataggenerator.org" size="50" />
← Enter URL into this field and click "Favicon Check" (use http://)<br />
<input type="submit" value="Favicon Check" />
</form><br />
<p> </p>
<?php
echo '<b>1.) First Function: Test to see if favicon exists</b><br />';
if (fileExists($path) == 1) {
echo "<img src=\"$path\"> ← Favicon is in the root directory";
} else {
echo 'There is no favicon in the root directory';
}
echo '<hr />';
echo '<b>2.) Second Function: Extract the Favicon tag and display if exists</b><br />';
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
I play with scripts as a hobby, but have a long way to go to catch up with some of the folks around here...
There is one place where this script misses the favicon, my previous script identified the URL, although it was a lot messier code... (like most of my code!)
Wow.
...
There is one place where this script misses the favicon, my previous script identified the URL, although it was a lot messier code... (like most of my code!)
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
My understanding is that browsers will only find it if it's a favicon.ico file in the site root, or else if it's specified in an appropriate link tag. Anything else, and the browser is not going to know about it (at least in terms of it being a favicon).
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
Bookmarks