Generate picture $width= "", $height = "50";//Generate a background, default black $img=imagecreatetruecolor ($width, $height);//Generate Color $background= Imagecolorallocate ($img, 200,200,200), $white =imagecolorallocate ($img, 255,255,255); $blue =imagecolorallocate ($img , 0,0,64);//Replace the back color Imagefill ($img, 0,0, $background);//Add line for ($i =1; $i <=10; $i + +) {$x 1=rand (0,100); $y 1=rand (0,50); $x 2=rand (0,100), $y 2=rand (0,50), Imageline ($img, $x 1, $y 1, $x 2, $y 2, Imagecolorallocate ($img, Mt_rand (0,255), Mt_rand ( 0,255), Mt_rand (0,255));} Join Dot for ($i =1; $i <100; $i + +) {Imagesetpixel ($img, Mt_rand (0,100), Mt_rand (0,), Imagecolorallocate ($img, Mt_rand (0,255), Mt_rand (0,255), Mt_rand (0,255));} Add the verification code $str= "abcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ23456789"; $code = ""; $count =strlen ($STR) -1;for ($i =1; $i <=4; $i + +) {$code. = $str [Mt_rand (0, $count)];} Imagestring ($img, $code, $blue);//Output Image header ("Content-type:image/png"); Imagepng ($img);