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