<?php
Header("Content-type: image/png");
function random($length=6) 
{
$hash = '';
$chars = '0123456789';
$max = strlen($chars) - 1;
mt_srand((double)microtime() * 1000000);
for($i = 0; $i < $length; $i++) 
$hash .= $chars[mt_rand(0, $max)];
return $hash;
}
$rand=random(6);
$_SESSION['randomcode']=$rand;
$im = imagecreate(60,25);
$white = ImageColorAllocate($im, 255,255,255);
$red = ImageColorAllocate($im, 255,0,0);
imagestring($im, 5, 4, 6,$rand, $red);
Imagepng($im);
ImageDestroy($im);
?>
产生随机数的