<?php
session_start();
header("Content-type:image/png");
$img_width=100;
$img_height=20;
srand(microtime()*100000);
for($i=0;$i<4;$i++)
{
$new_number.=dechex(rand(0,15));
}
$_SESSION[check_auth]=$new_number;
$new_number=imageCreate($img_width,$img_height);//创建图象
ImageColorAllocate($new_number,255,255,255); //设置背景色为白色
for($i=0;$i<strlen($_SESSION[check_auth]);$i++)
{
$font=mt_rand(3,5);
$x=mt_rand(1,8) + $img_width*$i/4;
$y=mt_rand(1,$img_height/4);
$color=imageColorAllocate($new_number,mt_rand(0,100),mt_rand(0,150),mt_rand(0,200));//设置字符颜色
imageString($new_number,$font,$x,$y,$_SESSION[check_auth][$i],$color);//输出字符
}
ImagePng($new_number);
ImageDestroy($new_number);
?>The GD library is a very powerful library for image manipulation in PHP. First add a line of reference in php.ini: extension=php_gd2.dllRestart apache. Make a test page var_dump(gd_info()); the output data shows that the GD library is referenced successfully. Form auth.html
Verification code library60742017-12-19
php verification code class
Verification code library100362017-11-16
php verification code generation class
Verification code library66962017-11-07
A PHP verification code encapsulation class that implements powerful and practical functions. Friends in need can download and use it.
Verification code library93822017-10-31
Code introduction: Free download of practical php verification code class
Verification code library65962017-07-02
Share aphp verification code generation class code,output the image to the browser through this method,create the image background,Set interference elements, Draw text randomly into the image, Output the image. ##
Verification code library93022017-06-20
IntroductionA class for php to generate image verification codes, is used to generate various verification codes, generate the character length, width, type, etc. of the verification code, friends in need Can be downloaded for reference.
Verification code library56912017-06-17
Introducing a useful verification code php tool class, take out the characters from the set string , combine them into the verification code characters we want, generate the code and then draw it into the picture.
Verification code library51012017-05-30
Share a PHP verification code class based on GD library, set the image height, width, number of characters, color font, image background, etc.
Verification code library52902017-05-06
ASimple and easy-to-use PHP verification code class.
Instructions:
$image=new Captcha();
$image->config('width','height','number of characters','verification code session index');
$image->create();//This will output an image to the browser
All parameters can be omitted
Verification code library94102017-04-10
Give you a #supports numbers, letters, Chinese characters, mixed php verification code class,this type The object can dynamically obtain the verification code image, and the verification code characters are stored in SESSION['code']. supports 4 formats of mixed numbers, letters, and Chinese characters.
Verification code library72382017-04-10
Needless to say the purpose of the verification code. After encapsulating it into a class, a constructor is added, which makes it easier to use. You can also continue to improve this verification code class, such as adding a destructor, how to save memory, etc.
Verification code library47922017-04-08