Presents a beautiful PHP verification code, can be adjusted according to individual needs, the code is as follows (aesthetic difference, welcome to spit Groove):
<?PHP/** * Author:xiongwei * Email: [EMAIL protected] * * Note: This code needs to use the Msyh.ttf font, please download it yourself **/Header("Content-type:image/png");//Image Size$width=180;$height=70;//font Style $font _style= './fontface/msyh.ttf ';//Font Size$font _size=28;//number of interference points$noise _num=40;//number of interference lines$line _num=10; $expression= ' abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz '; $expression=substr(Str_shuffle($expression), 0,4); $img=imagecreatetruecolor ($width,$height); $bdcolor=imagecolorallocate ($img, 170,170,170); $bgcolor=imagecolorallocate ($img, 250,250,250); Imagefilledrectangle ($img, 0, 0,$width,$height,$bgcolor); Imagerectangle ($img, 0, 0,$width-1,$height-1,$bdcolor);$x=10;$y=Ceil(($height+$font _size)/2); for($i= 0;$i<strlen($expression);$i++) {Imagettftext ($img,$font _size,Mt_rand( -30,30),$x,$y, Imagecolorallocate ($img,Mt_rand(0,255),Mt_rand(0,255),Mt_rand(0,255)),$font _style,$expression[$i]); $x+=30;} for($i= 0;$i<$noise _num;$i++) {Imagesetpixel ($img,Mt_rand(1,$width-1),Mt_rand(1,$height-1), Imagecolorallocate ($img,Mt_rand(0,255),Mt_rand(0,255),Mt_rand(0,255)));} for($i= 0;$i<$line _num;$i++) {Imagearc ($img,Mt_rand( -10,0),Mt_rand( -10,0),Mt_rand(20,400),Mt_rand(20,400), 50,44,imagecolorallocate ($img,Mt_rand(0,255),Mt_rand(0,255),Mt_rand(0,255))); //Imagearc ()}imagepng ($img); Imagedestroy ($img); ?>
The effect is as follows:
A beautiful handwritten php verification code