/*** Created by Phpstorm.* User:* DATE:2016/4/20* time:20:07 */session_start ();//draw a background map$image=imagecreatetruecolor ( -, -);$bgcolor=imagecolorallocate ($image,255,255,255);Imagefill ($image,0,0,$bgcolor);/*//generate four-bit random numbersFor ($i =0; $i <4; $i + +) {$f$f$f //where the numbers are displayed$x = ($i *100/4) +rand (5,9);$y =rand (5,10);imagestring ($image, $fonsize, $x, $y, $fontcontent, $foncolor); }*/$captch _code='';//generate digital letter mixed verification Code for($i=0;$i<4;$i++) {$fonsize=6;$fontcolor=imagecolorallocate ($image,rand (0, -),rand (0, -),rand (0, -));$data="abcdefghjklmnpqrstuvwxy13456789";$fontcontent=substr ($data,rand (0,strlen ($data)),1);$captch _code.=$fontcontent;//location of verification code$x=($i* -/4) +rand (5,Ten);$y=rand (5,Ten);//imagestring ($image,$fonsize,$x,$y,$fontcontent,$fontcolor);}$_session[' Authcode ']=$captch _code;//adding interference elements:Point for($i=0;$i< $;$i++) {$pointcolor=imagecolorallocate ($image,rand ( -, $),rand ( -, $),rand ( -, $));Imagesetpixel ($image,rand (1, About),rand (1, About),$pointcolor);}//Add interference element: line for($i=0;$i<3;$i++) {$linecolor=imagecolorallocate ($image,rand ( the, -),rand ( the, -),rand ( the, -));Imageline ($image,rand (1, About),rand (1, in),rand (1, About),rand (1, in),$linecolor);}Header (' Content-type:image/png ');Imagepng ($image);Imagedestroy ($image);?>
The above describes the php-generated verification code, including the verification Code, PHP content, I hope that the PHP tutorial interested in a friend helpful.