Php code to generate a cool verification code, php cool Verification Code
1 <? Php 2 $ im = imagecreate (200,100); // generate canvas 3 imagecolorallocate ($ im, 0, 0); // background color 4 $ white = imagecolorallocate ($ im, rand (0,255), rand (0,255), rand (0,255); // generates a random color of 5 for ($ I = 0; $ I <9; $ I ++) 6 {7 imageline ($ im, rand (0,200), rand (0,100), rand (0,200), rand (0,100), $ white ); // generate interference Line Element 8} 9 for ($ I = 0; $ I <150; $ I ++) 10 {11 imagesetpixel ($ im, rand (0,200 ), rand (0,100), $ white); // generate interference point element 12} 13 for ($ I = 0, $ str = ''; $ I <4; $ I ++) // obtain four words in a loop Break 14 {15 switch (rand () 16 {17 case '1': 18 $ ch = rand (); 19 break; 20 case '2 ': 21 $ ch = sprintf ('% C', rand (97,122); 22 break; 23 case '3': 24 $ ch = sprintf (' % C ', rand (65,90); 25 break; 26} 27 $ str. = $ ch; 28 29} 30 imagettftext ($ im, 32, rand (), 55,70, $ white, 'C. ttc ', $ str); // output string 31 header ("Content-type: image/jpeg") on the canvas; 32 imagejpeg ($ im ); 33 imagedestroy ($ im); 34?>