<?php
//=================================== "Use the drawing technique to draw the verification code
//1. Randomly generates 4 random numbers
$checkCode =" ";
For ($i =0 $i <4; $i + +) {
$checkCode. =dechex (1);//Decheck () decimal to 16, which is the number to display on the verification Code
}
//2. Save in column
session_start ();
$_session[' Checkcode ']= $checkCode;
3. Create canvas
$image 1=imagecreatetruecolor;
Manufacturing disturbances, creating 20 arcs for
($j =0 $j <30; $j + +) {
Imagearc ($image 1, rand (0), rand (0), rand (0, MB), rand (0, Rand (0, 360), rand (0, 360), Imagecolorallocate ($image 1, rand (0), rand (0, 255), rand (0, 255));
3. Create the font color, paste the word up
$white =imagecolorallocate ($image 1, 255, 255, 255);
Imagestring ($image 1, rand (2, 5), Rand (5), Rand (2,), $checkCode, $white);
5. Output image or Save
header ("Content-type:image/png");
Imagepng ($image 1);
6. Release of resources
Imagedestroy ($image 1);