A beautiful handwritten PHP verification code

Source: Internet
Author: User

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

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.