Jump to content


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


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
What am I missing?

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");
          return $img;
$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>" );

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.