Home >Backend Development >PHP Tutorial >Simple verification code generation, simple verification code generation_PHP tutorial

Simple verification code generation, simple verification code generation_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 08:51:19848browse

Simple verification code generation, simple verification code generation

for($i=0;$i<5;$i ){

$rand .= dechex(rand(1,15)); // Random number hexadecimal 1-F generates 5

}

$im = imagecreatetruecolor(100,30); // Verification code size (artboard)

$bg = imagecolorallocate($im, 0,0,0); // Background color

for($i<0;$i<100;$i ){

$color_dian = imagecolorallocate($im, rand(0,255),rand(0,255),rand (0,255));

imagesetpixel($im, rand()%100, rand()%30, $color_dian); // Draw points on the artboard

}

$color_font = imagecolorallocate($im, rand(88,255), rand(88,255), rand (100,255)); // Set the color of the color text

$color_line = imagecolorallocate($im, rand(0,255),rand(0,255),rand (0,255)); // Set the color of the color line

imageline($im, rand(1,10), rand(5,13), rand(80,100), rand(5,15), $color_line); // The line starts from the second parameter, the x-axis of the line head, the y-axis, and the end of the x-axis , y-axis, the color assigned

imagestring($im,5,rand(4,60), rand(3,10), $rand ,$color_font); //Write the generated code on the drawing board starting from the second parameter font attributes , the position x-axis, y-axis, random verification code, color displayed on the drawing board

// imagettftext($im, 12, 0, 12, 20, $color_font, 'haha.ttf', "I Ruthless"); Write on the drawing board

header("Content-type:image/jpeg"); // Declare what is to be output

imagejpeg($im); // Output the image in jpeg format to the browser

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1130671.htmlTechArticleSimple verification code generation, simple verification code generation for ($i= 0;$i 5;$i ) { $rand .= dechex( rand( 1, 15)); // Random number hexadecimal 1-F generates 5} $im = imagecreatetruecolor ( 100 , 30 )...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn