Use php to generate a verification code, and use php to generate a verification code
<? Php/*** php verification code generation * @ param $ width canvas width * @ param $ height canvas height * @ param $ vcodelen verification code length * @ param $ pointnum interference pixel count * @ param number of lines interfering with $ linenum ** train of thought: create a verification code canvas, generate and fill in the background color, generate the verification code content/interference pixel/line, fill in the canvas, and output. */$ Width = 100; $ height = 30; $ vcodelen = 4; $ pointnum = 200; $ linenum = 3; // create a canvas $ image = imagecreatetruecolor ($ width, $ height); // create a color block $ bgcolor = imagecolorallocate ($ image, 255,255,255); // fill the canvas background color imagefill ($ image, 0, 0, $ bgcolor ); // Verification Code content for ($ I = 0; $ I <$ vcodelen; $ I ++) {// font size $ fontsize = 5; // font color, the color is random within the specified range $ fontcolor = imagecolorallocate ($ image, rand (0,120), rand (0,120), rand (0, 120); $ data = 'abcdefghijklmnopqrstuvwxyz0123456789 '; // the content of the verification code is randomly intercepted in the above string $ fontcontent = substr ($ data, rand (0, strlen ($ data )), 1); // string display position $ x = ($ I * $ width/4) + rand (5, 15); $ y = rand (5, 10 ); // The font size of the string filling image // imagestring can be 1-5. The imagettftext function (font file required) imagestring ($ image, $ fontsize, $ x, $ y, $ fontcontent, $ fontcolor); // imagettftext ($ image, $ fontsize, 0, $ x, $ y, $ fontcolor, '/font/Geneva. dfont ', $ Fontcontent);} // interference pixel for ($ I = 0; $ I <$ pointnum; $ I ++) {$ pointcolor = imagecolorallocate ($ image, rand (0,120), rand (0,120), rand (0,120); // canvas fill pixel point function imagesetpixel ($ image, rand (0, $ width), rand (0, $ height), $ pointcolor);} // interfere with the line for ($ I = 0; $ I <$ linenum; $ I ++) {$ linecolor = imagecolorallocate ($ image, rand (0,120), rand (0,120), rand (0,120); // The canvas fill line function imageline ($ image, rand (0, $ width), rand (0, $ height), rand (0, $ width), rand (0, $ height), $ linecolor) ;}// the image output format header ('content-type: image/png '); // output the verification code image imagepng ($ image); // destroy the canvas imagedestroy ($ image);?>