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