<?php//If you don't understand the code, please see my previous article for a detailed answer. Digital Verification Code: http://my.oschina.net/u/2391943/blog/485163getValidate (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, 100, 30, $black); for ($i = 0; $i < 80; $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), $num2, $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;}}? >
Zhongzhiyuan Jiangsu Nanjing Zhongzhiyuan
PHP Verification Code of digital operation verification Code