1
Php2$im=imagecreate (200,100);//Generate Canvas3Imagecolorallocate ($im, 0,0,0);//Background color4$white=imagecolorallocate ($im,Rand(0,255),Rand(0,255),Rand(0,255) );//Generate random colors5 for($i= 0;$i<9;$i++)6{7Imageline ($im,Rand(0,200),Rand(0,100),Rand(0,200),Rand(0,100),$white);//Generate Disturbing line elements8}9 for($i= 0;$i<150;$i++)Ten{ OneImagesetpixel ($im,Rand(0,200),Rand(0,100),$white);//Generate Interference point elements A} - for($i=0,$str='';$i<4;$i++)//get four characters by Loop -{ theSwitch(Rand(1,3)) - { - Case' 1 ': -$ch=Rand(0,9); + Break; - Case' 2 ': +$ch=sprintf('%c ',Rand(97,122)); A Break; at Case' 3 ': -$ch=sprintf('%c ',Rand(65,90)); - Break; - } -$str.=$ch; - in} -Imagettftext ($im, 32,Rand(0,15), 55, 70,$white, ' C.TTC ',$str);//Output a string on the canvas toHeader("Content-type:image/jpeg"); +Imagejpeg ($im); -Imagedestroy ($im); the?>
The above describes the PHP write generated cool verification code, including the verification Code, PHP content, I hope to be interested in PHP tutorial friends helpful.