Simple verification code generation and simple verification code generation. Simple verification code generation, simple verification code generation for ($ i0; $ i5; $ I ++) {$ rand. dechex (rand (); random number in hexadecimal notation 1-F to generate 5} $ imimagecreatetruecolor () simple verification code generation, simple verification code generation
For ($ I = 0; $ I <5; $ I ++ ){
$ Rand. = dechex (rand (); // random number: hexadecimal 1-F to generate 5
}
$ Im = imagecreatetruecolor (, 30); // verification code size (canvas)
$ Bg = imagecolorallocate ($ im, 0, 0); // background color
For ($ I <0; I I <100; $ I ++ ){
$ Color_dian = imagecolorallocate ($ im, rand (0,255), rand (0,255), rand (0,255 ));
Imagesetpixel ($ im, rand () % 100, rand () % 30, $ color_dian); // draw a vertex on the canvas
}
$ Color_font = imagecolorallocate ($ im, rand (88,255), rand (88,255), rand (100,255); // set the color of the color text
$ Color_line = imagecolorallocate ($ im, rand (0,255), rand (0,255), rand (0,255); // set the color of the color line
Imageline ($ im, rand (80,100), rand (), rand (), $ color_line ); // The line starts from the second parameter. The line header has the x axis, Y axis, end x axis, Y axis, and assigned color.
Imagestring ($ im, 5, rand (4,60), rand (3,10), $ rand, $ color_font ); // write the generated code on the drawing board. the font attributes starting from the second parameter, the position x axis, Y axis, random verification code, and color displayed on the drawing board
// Imagettftext ($ im, 12, 0, 12, 20, $ color_font, 'Haha. ttf', ""); write on the canvas
Header ("Content-type: image/jpeg"); // declare what the output is
Imagejpeg ($ im); // output the image to the browser in jpeg format
Waiting for ($ I = 0; $ I 5; $ I ++) {$ rand. = dechex (rand (1, 15); // random number hex 1-F to generate 5} $ im = imagecreatetruecolor (100, 30 )...