Home > Backend Development > PHP Tutorial > PHP generates verification code example code_PHP tutorial

PHP generates verification code example code_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 17:41:13
Original
1011 people have browsed it

The following is the code to generate the verification code. The result was tested by Programming Home and there are no errors. If there is anything you don’t understand, you can reply and Programming Home will explain what you don’t understand. Hope it can be of benefit to you.

  1. session_start();
  2. $nums = rand(1000,9999);
  3. $_SESSION[nums]=$nums;
  4. $imgs = ImageCreatetruecolor(100, 35);
  5. $one = Imagecolorallocate($imgs, 0, 0, 0);
  6. $two = Imagecolorallocate($imgs, rand(0, 255), rand(0, 255), rand(0, 255));
  7. $thr = Imagecolorallocate($imgs, rand(50 , 200), rand(100, 255), rand(150, 255));
  8. Imagestring($imgs, 6, rand(5, 60), rand(3, 18), $nums, $ two);
  9. for ($i = 1; $i <= 3; $i ) {
  10. imageline($imgs, rand(0, 0), rand(0, 25 ), rand(70, 100), rand(0, 25), $thr);
  11. }
  12. for ($i = 1; $i <= 200; $i ) {
  13. imagesetpixel($imgs,rand() 0,rand()5,$two);
  14. }
  15. Header("Content-type:image/jpeg ");
  16. imagejpeg($imgs);
  17. ?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/486153.htmlTechArticleThe following is the code to generate the verification code. The result was tested by Programming Home and there are no errors. If there is anything you don’t understand, you can reply and Programming Home will explain what you don’t understand. ...
source:php.cn
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template