function getVerify()<br />{<br /><br /> session_start();<br /> ob_clean (); //清除缓冲区 <br /> header("Content-type:image/png");<br /><br /> $img_width=40;<br /> $img_height=20;<br /><br /> srand(microtime()*100000);<br /> for($i=0;$i<4;$i++)<br /> {<br /> $new_number.=dechex(rand(0,15));<br /> }<br /><br /> $_SESSION[check_auth]=$new_number;<br /> $new_number=imageCreate($img_width,$img_height);//创建图象<br /> ImageColorAllocate($new_number,255,255,255); //设置背景色为白色<br /><br /> for($i=0;$i<strlen($_SESSION[check_auth]);$i++)<br /> {<br /> $font=mt_rand(3,5);<br /> $x=mt_rand(1,1) + $img_width*$i/4;<br /> $y=mt_rand(1,$img_height/4);<br /> $color=imageColorAllocate($new_number,mt_rand(0,100),mt_rand(0,150),mt_rand(0,200));//设置字符颜色<br /> imageString($new_number,$font,$x,$y,$_SESSION[check_auth][$i],$color);//输出字符<br /> }<br /> //将验证码存入$_SESSION中<br /> $_SESSION["verify"]=$_SESSION[check_auth];<br /><br /> ImagePng($new_number);<br /> ImageDestroy($new_number);<br /><br />}