Simple verification code generation, simple verification code generation
for ($i =0; $i <5; $i + +) {
$rand. = Dechex (rand (1,15));//random number 16 binary 1-f generate 5
}
$im = Imagecreatetruecolor(+);//size of verification code (artboard)
$BG = Imagecolorallocate($im, 0,0,0);//Background color
For ($i <0; $i <$i + +) {
$color _dian = imagecolorallocate ($im, rand (0,255),rand (0,255),rand (0, 255));
Imagesetpixel ($im, rand ()%, rand ()%, $color _dian);//Draw points on the artboard
}
$color _font = imagecolorallocate ($im, rand (255), rand ( 255), Rand ( 255)); Set color for color text
$color _line = imagecolorallocate ($im, rand (0,255),rand (0,255),rand (0 ,255)); Set the color of a color line
Imageline ($im, rand (1,Ten), rand (5,), rand (+ 5,15) , $color _line); The x-axis, y-axis, end x-axis, y-axis, and assigned color of the thread starting from the second parameter
Imagestring ($im, 5,rand (4,60), Rand (3,10), $rand, $color _font); Write the generated code on the artboard properties of the font starting from the second argument, position displayed on the artboard x-axis, y-axis, random captcha, color
Imagettftext ($im, a, 0, a, a, $color _font, ' Haha.ttf ', "I'm Ruthless"); write on the artboard
Header("Content-type:image/jpeg");//Declare what is to be output
Imagejpeg($im);//output image to browser in JPEG format
http://www.bkjia.com/PHPjc/1130671.html www.bkjia.com true http://www.bkjia.com/PHPjc/1130671.html techarticle Simple verification Code generation, simple verification code generation for ($i = 0; $i 5; $i + +) {$rand. = Dechex (rand (1, 15));//random number 16 binary 1-f generate 5} $im = Imagecreatetruecolo R (+) ...