<?php
system("rm FOO*.gif");
$fn = tempnam("./","FOO") . ".gif";
$im = ImageCreate(300,300);
srand((double)microtime()*1000000);
$bg = ImageColorAllocate($im, rand() % 255,rand() % 255, rand() % 255);
$color = ImageColorAllocate($im, rand() % 255,rand() % 255, rand() % 255);
ImageLine($im,50,50, 50+(rand()%300), 50+(rand()%300), $color);
ImageGIF($im,$fn);
ImageDestroy($im);
?>
<img src=<?php echo $fn; ?>>
Note:
Why am I generating a unique filename?
This something I discovered about putting an image in the document. Even if you create a dynamic chart and put in the image. The browser won't display the newly/updated generated image, although the image is already changed/ try to see the image file timestamp /. In order to inform the browser that the image is a new one, always generate a new name for the image. Or if you won't, the only way for the browser to reflect the newly generated image is to force refresh the page, and you can do this by manually pressing the shift then click the refresh/reload button.