PHP Digital Operation Verification Code implementation codes, PHP digital Operation verification Code _php tutorial

Source: Internet
Author: User

Implementation code of PHP digital Operation verification Code, PHP digital Operation Verification Code


In this paper, the method of implementing digital operation verification Code in PHP is described, and the implementation method is as follows:

<?phpgetvalidate (100,30);   function Getvalidate ($w, $h) {$img = Imagecreate ($w, $h);  $gray = Imagecolorallocate ($img, 255,255,255);  $black = Imagecolorallocate ($img, Rand (0,200), Rand (0,200), Rand (0,200));  $red = Imagecolorallocate ($img, 255, 0, 0);  $white = Imagecolorallocate ($img, 255, 255, 255);  $green = imagecolorallocate ($img, 0, 255, 0);  $blue = imagecolorallocate ($img, 0, 0, 255);    Imagefilledrectangle ($img, 0, 0, +, $black);  for ($i = 0; $i <; $i + +) {Imagesetpixel ($img, rand (0, $w), rand (0, $h), $gray);  } $num 1 = rand (1,99);   $num 2 = rand (1,99);  Imagestring ($img, 5, 5, rand (1,10), $num 1, $red);  Imagestring ($img, 5,30,rand (1,10), Getrand (), $white);  Imagestring ($img, 5,45,rand (1,10), $num 2, $green);  Imagestring ($img, 5,65,rand (1,10), "=", $blue);      Imagestring ($img, 5,80,rand (1,10), "?", $red);  Header ("Content-type:image/png");  Imagepng ($IMG); Imagedestroy ($img);}  function Getrand () {$code = rand (0,1);      Switch ($code) {case 0:return "+"; BrEak      Case 1:return "-";    Break  Default: # code ... break; }}?>

Implementation results:

The above is the use of PHP to implement the digital Operation verification code method, I hope that everyone's learning is helpful.

http://www.bkjia.com/PHPjc/1040815.html www.bkjia.com true http://www.bkjia.com/PHPjc/1040815.html techarticle PHP Digital Operation Verification Code implementation codes, PHP digital operation Verification Code in this paper, a practical example of PHP implementation of digital operation verification Code method, the implementation method is as follows: Phpgetvalidate (100,30) ...

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