PHP write generate cool Verification Code yii2 Code Verification Code PHP image PHP Verification code does not display

Source: Internet
Author: User
Tags php write
1 
 Php2$im=imagecreate (200,100);//Generate Canvas3Imagecolorallocate ($im, 0,0,0);//Background color4$white=imagecolorallocate ($im,Rand(0,255),Rand(0,255),Rand(0,255) );//Generate random colors5 for($i= 0;$i<9;$i++)6{7Imageline ($im,Rand(0,200),Rand(0,100),Rand(0,200),Rand(0,100),$white);//Generate Disturbing line elements8}9 for($i= 0;$i<150;$i++)Ten{ OneImagesetpixel ($im,Rand(0,200),Rand(0,100),$white);//Generate Interference point elements A} - for($i=0,$str='';$i<4;$i++)//get four characters by Loop -{ theSwitch(Rand(1,3)) -    { - Case' 1 ': -$ch=Rand(0,9); + Break;  - Case' 2 ': +$ch=sprintf('%c ',Rand(97,122)); A Break; at Case' 3 ': -$ch=sprintf('%c ',Rand(65,90)); - Break; -    } -$str.=$ch; - in} -Imagettftext ($im, 32,Rand(0,15), 55, 70,$white, ' C.TTC ',$str);//Output a string on the canvas toHeader("Content-type:image/jpeg"); +Imagejpeg ($im); -Imagedestroy ($im); the?>

The above describes the PHP write generated cool verification code, including the verification Code, PHP content, I hope to be interested in PHP tutorial friends helpful.

  • 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.