How to use the PHP plot function to implement the simple verification code function _ php instance

Source: Internet
Author: User
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 ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.