Answer: PHP verification box

Source: Internet
Author: User
Answer: The following content in the PHP verification box is excerpted from PHPWeb2.0 development practices. for Chinese counterparts, you can use the Text_CAPTCHA component provided by PEAR (PHP extension and application library) to generate CAPTCHA images. First install: can be downloaded, also available pear command pearinstallText_Passwordpearinstall-fText_CAPTCHApearinsta reply: PHP verification box
The following content is excerpted from a Chinese translation written by foreigners in PHP development practices

You can use the Text_CAPTCHA component provided by PEAR (PHP extension and application library) to generate CAPTCHA images.

Install it first: you can download it or use the pear command.
Pear install Text_Password
Pear install-f Text_CAPTCHA
Pear install-f Image_Text

This package depends on the other two. I tried to generate random characters.
You also need a font file with the suffix ttf. There are many online files,

// The following is createImage. php include (Text_CAPTCHA file); // if the include path already points to the pear directory, you can skip this sentence $ captcha = Text_CAPTCHA: factory ('image '); // Generate object first // The following is the size, path of the font file, font file name $ opts = array ('font _ size' => 20, 'font _ path' => Zend_Registry: get ('config')-> paths-> data, 'font _ file' => 'verabd. ttf'); $ phare = custom random number; $ captcha-> init (120, 60, $ phrase, $ opts ); // 120 and 60 are the width and height of the generated image. // Here I select the png image. jpg header ('content-type: image/png ') is also available '); echo $ captcha-> getCAPTCHAAsPng ();


// Test.html


Is it easy? 82.95.186.47: 9001 850246527


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.