How to create a script that, when accessed as an image, generates a random image every time its loaded:
1: Create a php file like this:
<?php
// Directory of images
$folder = 'images/';
// Do not edit any code below!
srand( time() );
if ($directory = @opendir($folder))
{
while (($image = readdir($directory)) !== false)
{
if ( eregi( '.(png|gif)$', $image) )
{
$images[] = $image;
}
}
closedir($directory);
}
$image = $images[rand() % sizeof( $images )];
if ( eregi( '.png$', $image ))
{
header("Content-Type: image/png");
}
else
{
header("Content-Type: image/gif");
}
header("Content-Length: " . filesize( $folder."/".$image ) );
readfile( $folder."/".$image );
?>
2: Save this file on your server, in a folder named 'random' (Or whatever name you want)
3: In the folder the Php file is in, create another folder and name it 'images' (You can name it something else, but in the script change the $folder variable to the name / path you use). In this folder put all the .png / .gif images you want in the randomizer.
4: To put the random image on your site:
<image src="PATH TO PHP FILE">
Or as a sig on a forum:
[img]URL OF PHP FILE[/img]
Example of it:

(Refresh the page to change)
Enjoy!
Note: This script above is for .gif and .png images ONLY! You can change it to other formats by changeing all instances of 'gif' or 'png' to whatever format you want. (But who would want to, png and gif are the best formats anyway)
Note yet again: Some (bad) browers will show the image as not available. I know it works for sure on Safari / Firefox on Mac OsX, and
beleive it works on Firefox for Windows. Also, I know it doesn't work on IE for Mac OsX. Not sure about other browers / systems.