session_start();
header("Content-type: image/jpeg");
$img = imagecreate(50,20);
$white = imagecolorallocate($img,211,213,193);
imagefill($img,0,0,$white); for($i=0;$i
$r[$i] = rand(0,9);
}
$_SESSION['valid'] = implode("",$r); //在这里写入到session可做后期验证
for($i=0;$i
if(rand(0,9)%2==0){
imagechar($img,5,($i+1)*8,4,$r[$i],imagecolorallocate($img,rand(0,150),rand(0,150),rand(0,150)));
}else{
imagechar($img,5,($i+1)*8,2,$r[$i],imagecolorallocate($img,rand(0,150),rand(0,150),rand(0,150)));
}
}
imagejpeg($img);
|