PHP generates cool four character verification code, PHP generates cool verification code
The example of this article for everyone to share the code of PHP generated verification codes, for your reference, the specific content as follows
<?php$im=imagecreate (200,100);//Generate Canvas Imagecolorallocate ($im, 0,0,0);//background-color $white=imagecolorallocate ($im, Rand ( 0,255), Rand (0,255), Rand (0,255));//Generate Random color for ($i =0; $i <9; $i + +) {Imageline ($im, Rand (0,200), Rand (0,100), Rand ( 0,200), Rand (0,100), $white);//Generate Interference line elements}for ($i =0; $i <150; $i + +) {Imagesetpixel ($im, Rand (0,200), Rand (0,100), $ white);//Generate a disturbance point element}for ($i =0, $str = "; $i <4; $i + +)//To get four characters {switch (rand (1,3)) {case ' 1 ': $ch =rand (0,9); break; Case ' 2 ': $ch =sprintf ('%c ', rand (97,122)); break; Case ' 3 ': $ch =sprintf ('%c ', rand (65,90)); Break } $str. = $ch;} Imagettftext ($im, 32,rand (0,15), 55,70, $white, ' C.TTC ', $str);//output string header on canvas ("Content-type:image/jpeg"); Imagejpeg ($im); Imagedestroy ($im);? >
The above is the whole content of this article, I hope that you learn PHP programming help.
http://www.bkjia.com/PHPjc/1122891.html www.bkjia.com true http://www.bkjia.com/PHPjc/1122891.html techarticle PHP generated cool four character verification code, PHP generated cool code in this example for everyone to share PHP code to generate verification codes for your reference, specific content as follows Php$im=imagec ...