Page 1 of 1

trying to make random favicons

Posted: Sun Jun 25, 2006 3:52 pm
by tefflox
I'm new to web development. You can see the extent of my php experience at http://listenlight.net/hello.php

Now I'm trying to make random favicons. Here is what I've got so far..

Code: Select all

<?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));
       if( imagefilledellipse($img, 8, 8, 12, 16, $ec) ) {
         header("Content-type: image/png");
         imagepng($img);
         return $img;
        } else ??
                 
?>
if I can get that to work, then I have to figure out how the link works. What to do?

Posted: Wed Jun 28, 2006 2:26 pm
by kendall
LOL....dude,

first off that aint "favicons" so u "mite" have a hard time getting them to display...

secondly try http://www.chami.com/html-kit/services/favicon/

Posted: Wed Jun 28, 2006 3:35 pm
by RobertGonzalez
Why not just create a default image and set a return variable with the value of the default. Work the function and if everything works, then set the return variable to the value of the random favicon. If it doesn't work, well you have already set a default so that will be returned.