Simple verification code generation, simple verification code Generation _php Tutorial

Source: Internet
Author: User

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

  • Related Article

    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.