Simple php verification code generation
// Generate an image $ width = "100"; $ height = "50"; // Generate a background. the default value is black $ img = imagecreatetruecolor ($ width, $ height ); // generate color $ background = imagecolorallocate ($ img, 200,200,200); $ white = imagecolorallocate ($ img, 255,255,255); $ blue = imagecolorallocate ($ img, 64 ); // replace the back color imagefill ($ img, $ background); // add the line for ($ I = 1; $ I <= 10; $ I ++) {$ x1 = rand (0,100); $ y1 = rand (0,100); $ x2 = rand (); $ y2 = rand (); imageline ($ img, $ x1, $ y1, $ x2, $ y2, imagecolorallocate ($ img, mt_rand (0,255), mt_rand (0,255), mt_rand (0,255 )));} // add a small dot for ($ I = 1; $ I <100; $ I ++) {imagesetpixel ($ img, mt_rand (0,100), mt_rand (0, 50 ), imagecolorallocate ($ img, mt_rand (0,255), mt_rand (0,255), mt_rand (0,255);} // add the verification code $ str = "login"; $ code = ""; $ count = strlen ($ str)-1; for ($ I = 1; $ I <= 4; $ I ++) {$ code. = $ str [mt_rand (0, $ count)];} imagestring ($ img, 12, 20, 20, $ code, $ blue ); // output image header ("content-type: image/png"); imagepng ($ img );