Copy codeThe Code is as follows:
<? Php
Function yzm ($ name, $ width, $ height ){
Header ("Content-type: image/PNG ");
Srand (double) microtime () * 1000000); // play the next seed that generates random numbers to facilitate the use of the following Random Number Generation
Session_start (); // Save the random number to the session.
$ _ SESSION [$ name] = "";
$ Im = imagecreate ($ width, $ height); // specify the image background size.
$ Black = ImageColorAllocate ($ im, 0, 0); // you can specify three colors.
$ White = ImageColorAllocate ($ im, 255,255,255 );
$ Gray = ImageColorAllocate ($ im, 200,200,200 );
Imagefill ($ im, $ gray); // use the area filling method, set)
While ($ authnum = rand () % 100000) <10000 );
$ _ SESSION [$ name] = $ authnum;
Imagestring ($ im, 5, 10, 3, $ authnum, $ black );
For ($ I = 0; $ I <200; $ I ++) // Add interference pixels
{
$ Randcolor = ImageColorallocate ($ im, rand (0,255), rand (0,255), rand (0,255 ));
Imagesetpixel ($ im, rand () % 70, rand () % 30, $ randcolor );
}
ImagePNG ($ im );
ImageDestroy ($ im );
}?>
Create a php file into yzm. php and call
Call this function.