PHP verification code generation-memo & lt ;? Phpsession_start (); save the generated value to compare it with user input ------------------------------------- $ img_w80; set the image width $ img_h20; set the image height $ pixel_num200; more vertices, more interference. $ I PHP verification code generation-memo
$ Val) {if ($ I> 0) {$ wid + = $ val ['width'];} imagestring ($ im, $ val ['font'], $ offset_x + $ wid, $ val ['offset'] + $ offset_y, $ val ['char '], $ val ['color']); $ I ++ ;} switch ($ pixel_mode) {case 1: $ pixel_color = ImageColorAllocate ($ im, mt_rand (50,255), mt_rand (50,255), mt_rand (50,255 )); // interfere with pixels for ($ I = 0; $ I <$ pixel_num; $ I ++) {imagesetpixel ($ im, mt_rand () % $ img_w, mt_rand () % $ img_h, $ pixel_color);} break; case '2': // interference pixel for ($ I = 0; $ I <= 128; $ I ++) {$ pixel_color = imagecolorallocate ($ im, rand (0,255 ), rand (0,255), rand (0,255); imagesetpixel ($ im, mt_rand (2,128), mt_rand (), $ pixel_color);} break; default: $ pixel_color = ImageColorAllocate ($ im, mt_rand (50,255), mt_rand (50,255), mt_rand (50,255); // interfere with pixels for ($ I = 0; $ I <$ pixel_num; $ I ++) {imagesetpixel ($ im, mt_rand () % $ img_w, mt_rand () % $ img_h, $ pixel_color );} Break;} ImagePNG ($ im);?>