Php generates a cool four-character verification code, and php generates a cool verification code. Php generates a cool four-character verification code. php generates a cool verification code. in this article, we will share with you the implementation code of the php verification code for your reference, the specific content is as follows: php $ imimagec php generates a cool four character verification code, and php generates a cool verification code
The example in this article shares the implementation code of the php verification code for your reference. The details are as follows:
<? Php $ im = imagecreate (200,100); // Generate the canvas imagecolorallocate ($ im, 0, 0); // background color $ white = imagecolorallocate ($ im, rand (0,255 ), rand (0,255), rand (0,255); // generates a random color for ($ I = 0; $ I <9; $ I ++) {imageline ($ im, rand (0,200), rand (0,100), rand (0,200), rand (0,100), $ white); // generates interference line elements} for ($ I = 0; $ I <150; $ I ++) {imagesetpixel ($ im, rand (0,200), rand (0,100), $ white ); // generate interference point element} for ($ I = 0, $ str = ''; $ I <4; $ I ++) // Obtain Four characters {switch (rand (1, 3) {case '1': $ c H = rand (97,122); break; case '2': $ ch = sprintf ('% c', rand (); break; case '3 ': $ ch = sprintf ('% c', rand (65,90); break;} $ str. = $ ch;} imagettftext ($ im, 32, rand (), $ white, 'C. ttc ', $ str); // output the string header ("Content-type: image/jpeg") on the canvas; imagejpeg ($ im ); imagedestroy ($ im);?>
The above is all the content of this article. I hope it will help you learn PHP programming.
Examples in this article share the implementation code of the php verification code for your reference. the specific content is as follows: php $ im = imagec...