Verification code in PHP is often used, the following we provide you with some of the PHP verification code generation class and program, directly copied down can be directly used, oh, see the code below.
Verification code in the PHP tutorial is often used, below we provide you with some about PHP code generation class and program, directly copied down can be directly used, oh, see the code below.
Session_Start ();
Header ("Content-type:image/gif");
Class Securitycode
{
Private $codes = ';
function __construct ()
{
$code = ' 0-1-2-3-4-5-6-7-8-9-a-b-c-d-e-f-g-h-i-j-k-l-m-n-o-p-q-r-s-t-u-v-w-x-y-z ';
$codeArray = Explode ('-', $code);
Shuffle ($codeArray);
$this->codes = Implode (", Array_slice ($codeArray, 0,4));
}
Public Function createimg ()
{
$_session[' check_pic ' = $this->codes;
$img = Imagecreate (70,25);
Imagecolorallocate ($img, 222,222,222);
$testcolor 1 = imagecolorallocate ($img, 255,0,0);
$testcolor 2 = imagecolorallocate ($img, 51,51,51);
$testcolor 3 = imagecolorallocate ($img, 0,0,255);
$testcolor 4 = imagecolorallocate ($img, 255,0,255);
for ($i = 0; $i < 4; $i + +)
{
Imagestring ($img, Rand (5,6), 8 + $i * 15,rand (2,8), $this->codes[$i],rand (1,4));
}
Imagegif ($IMG);
}
}
$code = new Securitycode ();
$code->createimg ();
$code = NULL;
?>
Code two
session_start ();
for ($i =0; $i <4; $i + +) {
$rand. = Dechex (rand (1,15));
}
$_session[check_pic]= $rand;
Echo $_session[check_pic];
Set Picture size > Picture size
$im = Imagecreatetruecolor (100,30);
Set color
$BG =imagecolorallocate ($im, 0,0,0);
$te =imagecolorallocate ($im, 255,255,255);
Write the string in the upper left corner of the image
Imagestring ($im, Rand (5,6), Rand (25,30), 5, $rand, $te);
Output image
Header ("Content-type:image/jpeg");
Imagejpeg ($im);
?>
http://www.bkjia.com/PHPjc/632979.html www.bkjia.com true http://www.bkjia.com/PHPjc/632979.html techarticle Verification Code in PHP is often used, the following we provide you with some of the PHP verification code generation class and program, directly copied down can be directly used, oh, see the code below. Verify ...