Php implements Verification Code production, and php implements Verification Code
First, let's take a look at the general effect.
Then, paste the Code directly.
<? Php $ image = imagecreatetruecolor (100, 30); // create a canvas $ imagecolor = imagecolorallocate ($ image, 255,255,255); // background color imagefill ($ image, 0, 0, $ imagecolor); // fill in the background color for ($ I = 0; $ I <4; $ I ++) {// loop 4 digits $ fontsize = 6; $ fontcolor = imagecolorallocate ($ images, rand (0,200), rand (0,200), rand (0,200); $ fontcontent = rand (0, 9 ); $ x = $ I * 100/4 + rand (5, 15); $ y = rand (5, 10); imagestring ($ image, $ fontsize, $ x, $ y, $ Fontcontent, $ fontcolor);} for ($ I = 0; $ I <200; $ I ++) {// Add interference points cyclically $ pointcolor = imagecolorallocate ($ image, rand (50,200), rand (50,200), rand (50,200); $ x = rand (1, 99); $ y = rand (1, 29 ); imagesetpixel ($ image, $ x, $ y, $ pointcolor) ;}for ($ I = 0; $ I <3; $ I ++) {// Add interference lines cyclically $ linecolor = imagecolorallocate ($ image, rand (100,250), rand (100,250), rand (100,250); $ x1 = rand (1, 25); $ x2 = rand (50, 75); $ y1 = r And (1, 15); $ y2 = rand (15, 25); imageline ($ image, $ x1, $ y1, $ x2, $ y2, $ linecolor );} header ("content-type: image/png"); imagepng ($ image); imagedestroy ($ image);?>