Jump to content

Archived

This topic is now archived and is closed to further replies.

tefflox

newbie project: random favicon?

Recommended Posts

the idea is to make an elliptical favicon of random color that is new for each page load. here's what i've got so far. the page / source is [url=http://listenlight.net/createpng.php]http://listenlight.net/createpng.php
[/url]
What am I missing?

[code]<?php
function randomFavicon() {
          $img = imagecreatetruecolor(16, 16); /* Create a blank image */
          $bgc = imagecolorallocate($img, rand(1,160), rand(1,160),rand(1,160));
          $ec  = imagecolorallocate($img, rand(1,160), rand(1,160),rand(1,160));
          imagefilledellipse($img, 8, 8, 12, 16, $ec);
          //header("Content-type: image/png");
          imagepng($img);
          
          return $img;
         }      
?>
<?php
$favipng = randomFavicon();

  echo( "<link rel=\"icon\" href=\"".$favipng."\" type=\"image/x-icon\" /><br /><link rel=\"shortcut icon\" href=\"".$favipng."\" type=\"image/x-icon\" /><br />");

  echo ( "<title> testing </title>" );
?>[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.