红色部分显示错误 就大神指教 谢谢
session_start();
$width=60;
$height=20;
$img=imagecreatetruecolor($width,$height);
$time=4;
$arr2=range(0,9);
$arr=array_merge($arr2);
$keys=array_rand($arr,$time);
$str="";
foreach($keys as $i)
$str.=$arr($i);
$_SESSION["randValid"]=$str;
for($i=0;$i<$time*2;$i++){
$color=imgecolorallocate($img,rand(0,156),rand(0,156),rand(0,156),);
imageline($img,rand(0,$width),rand(0,$height),rand(0,$width),rand(0,$height),$color);
$color=imagecolorallocate($img,rand(0,255),rand(0,255),rand(0,255),);
imagesetpixel($img,rand(0,$width),rand(0,$height),$color);
}
$color=imagecolorallocate($img,255,255,255);
imagestring($img,5,5,3,$str,$color);
header("content-type:image/png");
imagepng($img);
imagedestroy($img);
?>