This is an example of outputting four verification codes. for Chinese characters, you need the font file and the imagettftext function. you can search for them online. Instance 22: Core Image Verification code
The code is as follows:
// Header ("content-type: image/png ");
$ Num = '000000 ';
$ Imagewidth = 60;
$ Imageheight = 18;
$ Numimage = imagecreate ($ imagewidth, $ imageheight );
Imagecolorallocate ($ numimage, 240,240,240 );
For ($ I = 0; $ I $ X = mt_rand (1, 8) + $ imagewidth * $ I/4;
$ Y = mt_rand (1, $ imageheight/4 );
$ Color = imagecolorallocate ($ numimage, mt_rand (0,150), mt_rand (0,150), mt_rand (0,150 ));
Imagestring ($ numimage, 5, $ x, $ y, $ num [$ I], $ color );
}
For ($ I = 0; I I <200; $ I ++ ){
$ Randcolor = imagecolorallocate ($ numimage, rand (200,255), rand (200,255), rand (200,255 ));
Imagesetpixel ($ numimage, rand () % 70, rand () % 20, $ randcolor );
}
Imagepng ($ numimage );
Imagedestroy ($ numimage );
?>
This is an example of outputting four verification codes. for Chinese characters, you need the font file and the imagettftext function. you can search for them online. If you want to generate a random number, there is the mt_rand function. you also need to use session to save the random number. if you want to convert it to UTF-8, you need the iconv function.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.