Copy CodeThe code is as follows:
function Yzm ($name, $width, $height) {
Header ("Content-type:image/png");
Srand (Double) microtime () *1000000);//sow a seed that generates random numbers to facilitate the use of random number generation below
Session_Start ();//storing random numbers in session
$_session[$name]= "";
$im = Imagecreate ($width, $height); Make picture background size
$black = Imagecolorallocate ($im, 0,0,0); Set of three Colors
$white = Imagecolorallocate ($im, 255,255,255);
$gray = Imagecolorallocate ($im, 200,200,200);
Imagefill ($im, 0,0, $gray); Using area Fill method, set (0,0)
while (($authnum =rand ()%100000) <10000);
$_session[$name]= $authnum;
Imagestring ($im, 5, 3, $authnum, $black);
for ($i =0; $i <200; $i + +)//Add interfering pixels
{
$randcolor = Imagecolorallocate ($im, Rand (0,255), Rand (0,255), Rand (0,255));
Imagesetpixel ($im, Rand ()%70, Rand ()%30, $randcolor);
}
Imagepng ($im);
Imagedestroy ($im);
}?>
Use the method to create a PHP file into the yzm.php, calling
Call the parameters into this function.
The above introduces the simple hanging 2.5.5 Beta free version of the simple PHP verification image generation function, including the simple hanging 2.5.5 Beta free version of the content, I hope that the PHP tutorial interested friends have helped.