This site is originally reprinted, please indicate here
<? Php
Session_start ();
Header ("content-type: image/png"); set the format of the generated image to png.
$ Width = 40; // width
$ Height = 25; // height
$ Color = "# ffffff"; // color
$ Num = rand (,); // generates a random number of four digits
$ _ SESSION ['ver '] = $ num; Save to session for verification
$ Img = imagecreate ($ width, $ height); // use imagecreate to create an image
$ Bg1 = imagecolorallocate ($ img, rand (0,100), rand (0,250), rand (0,255); // image color collection
$ Bg2 = imagecolorallocate ($ img, rand (0,205), rand (0,250), rand (0,245 ));
// Imageline ($ img, 40, 20, 40, 40, $ color );
// Imagesetpixel ($ img, 44,44, $ color );
Imagestring ($ img, 7,4, 7, $ num, $ bg2); // Add a miscellaneous
Imagepng ($ img); // generates an image
Imagedestroy ($ img); // destroy
?>
This is very simple, so I will not discuss it in detail.