PHP generates simple verification codes based on PHP. Based on PHP to generate a simple verification code, PHP to generate a simple verification code is not enough to talk about, directly paste code for everyone, the specific code is as follows: for ($ i0; $ i5; $ I ++) {$ rand. dechex (rand (simple verification code generated based on PHP, simple verification code generated by PHP
If you don't talk much about it, paste the code directly. the specific code is as follows:
For ($ I = 0; $ I <5; $ I ++) {$ rand. = dechex (rand (); // A random number is generated in hexadecimal notation 1-F.} $ im = imagecreatetruecolor (); // the verification code size (canvas) $ bg = imagecolorallocate ($ im, 100, 0); // background color for ($ I <0; $ I <; $ 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 line imageline ($ im, rand (80,100), rand (), rand (), $ color_line ); // The line starts from the second parameter. the x axis and y axis of the line header, the end x axis, the y axis, the assigned color imagestring ($ im, 5, rand (), rand ), $ rand, $ color_font ); // write the generated code on the canvas. the font attributes start from the second parameter, the position x axis, Y axis, random verification code, and color displayed on the canvas. // imagettftext ($ im, 12, 0, 12, 20, $ color_font, 'Haha. ttf', ""); write the header ("Content-type: image/jpeg") on the canvas "); // declare what you want to output imagejpeg ($ im); // output the image to the browser in jpeg format
The above code is a simple verification code generated based on PHP introduced by the small Editor. the code is accompanied by a comment. if you have any questions during the reference process, please leave a message to me. The small editor will reply to you in time.
I don't need to talk about it anymore. I just paste the code directly. the specific code is as follows: for ($ I = 0; $ i5; $ I ++) {$ rand. = dechex (rand (...