PHP Easy Verification Code

Source: Internet
Author: User
PHP Simple Verification Code
 
 Length $i + +) {//cyclic random-fetch characters generate string $strnum. = $strings [rand (0, $count-1)];} Session_Start (); $_session ["verifycode"] = $strNum; $this->im = Imagecreate ($this->width, $this->height); $ BackgroundColor = Imagecolorallocate ($this->im, 255, 255, 255);  Generate background color $framecolor = imagecolorallocate ($this->im, 0, 255, 0); for ($i = 0; $i < $this->length; $i + +) {$charY = ($this->height + 9)/2 + rand (-1, 1); Defines the character y coordinate $charx = $i * 15 + 8;                                                Defines the character X coordinate//$text _color = imagecolorallocate ($this->im, 255, 0, 0); Generate character Color $text_color = Imagecolorallocate ($this->im, Mt_rand (255), Mt_rand (50, 2 ) $angle = rand (-20, 20); Generate character angle//write character imagettftext ($this->im, $this->fontsize, $angle, $charX, $charY, $text _color, $this->font, $ Strnum [$i]);} for ($i = 0; $i <= 5; $i + +) {//cycle draw background Line $linecolor = Imagecolorallocate ($this->im, Mt_rand (0, 255), Mt_rand (0, 255 ), Mt_rand (0, 255)); $linex = Mt_rand (1, $this->width-1); $liney = Mt_rand (1, $this->height-1); Imagelin E ($this->im, $linex, $liney, $linex + mt_rand (0, 4)-2, $liney + mt_rand (0, 4)-2, $linecolor);} for ($i = 0; $i <=; $i + +) {//cycle draw background points, create $pointcolor = Imagecolorallocate ($this->im, Mt_rand (0, 255), Mt_r and (0, 255), Mt_rand (0, 255)), Imagesetpixel ($this->im, Mt_rand (1, $this->width-1), Mt_rand (1, $this- >height-1), $pointcolor);} Imagerectangle ($this->im, 0, 0, $this->width-1, $this->height-1, $frameColor); Draw Border Ob_clean (); header (' content-type:image/png '); Imagepng ($this->im); Imagedestroy ($this->im);}} $img = new Verifyimg (); $img->build ();? >
  • 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.