The following small series will bring you a simple verification code function using PHP plot functions. I think this is quite good. now I will share it with you and give you a reference. Let's take a look at it with Xiaobian.
Index. php
<? Php // ================================================" use the drawing technology to plot the verification code // 1. generates 4 random numbers $ checkCode = ""; for ($ I = 0; $ I <4; $ I ++) {$ checkCode. = dechex (rand (1, 15); // decheck () decimal conversion to hexadecimal format, that is, the number to be displayed on the verification code} // 2. saved column session_start (); $ _ SESSION ['checkcode'] = $ checkCode; // 3. create canvas $ image1 = imagecreatetruecolor (100, 30); // create interference and create 20 arcs for ($ j = 0; $ j <30; $ j ++) {imagearc ($ image1, rand (0,100), rand (0, 30), rand (0,100), rand (0, 30), rand (0,360), rand (0,360 ), imagecolorallocate ($ image1, rand (0,155), rand (0,255), rand (0,255);} // 3. create a font color, paste the word $ white = imagecolorallocate ($ image1, 255,255,255); imagestring ($ image1, rand (2, 5), rand (5, 70 ), rand (2, 15), $ checkCode, $ white); // 5. output image or save header ("content-type: image/png"); imagepng ($ image1); // 6. release the resource imagedestroy ($ image1 );
Login. php
Enter the verification code:
The above is all the content of the simple verification code function implemented by using the PHP drawing function provided by Xiaobian. I hope you can provide more support ~