Copy CodeThe code is as follows:
function _code ($_code_length = 4, $_width =, $_height = 25) {
for ($i =0; $i <$_code_length; $i + +) {
$_nmsg. = Dechex (Mt_rand (0,15));
}
$_session["Code" = $_nmsg;
$_img = Imagecreatetruecolor ($_width, $_height);
$_white = Imagecolorallocate ($_img, 250, 250, 250);
Imagefill ($_img, 0, 0, $_white);
$_gray = Imagecolorallocate ($_img, 196, 196, 196);
Imagerectangle ($_img, 0, 0, $_width-1, $_height-1, $_gray);
for ($i =0; $i < 6; $i + +) {
$_md_color = Imagecolorallocate ($_img, Mt_rand (200,255), Mt_rand (200,255), Mt_rand (200,255));
Imageline ($_img, Mt_rand (0,$_width), Mt_rand (0, $_height), Mt_rand (0,$_width), Mt_rand (0, $_height), $_md_color);
}
for ($i =0; $i < $i + +) {
$_md_color = Imagecolorallocate ($_img, Mt_rand (200,255), Mt_rand (200,255), Mt_rand (200,255));
Imagestring ($_img, 1, Mt_rand (1,$_width-5), Mt_rand (1, $_height-5), "*", $_md_color);
}
for ($i =0; $i < $_code_length; $i + +) {
$_md_color = Imagecolorallocate ($_img, Mt_rand (0,102), Mt_rand (0,102), Mt_rand (0,102));
Imagestring ($_img, 5, $i * $_width/$_code_length+ mt_rand (1, ten), Mt_rand (1, $_HEIGHT/2), $_session["code" [$i], $_md_ color);
}
Header ("Content-type:image/png");
Imagepng ($_IMG);
Imagedestroy ($_IMG);
}
http://www.bkjia.com/PHPjc/327056.html www.bkjia.com true http://www.bkjia.com/PHPjc/327056.html techarticle Copy the code as follows: function _code ($_code_length = 4, $_width =, $_height =) {for ($i =0; $i $_code_length; $i + +) {$_nmsg. = d Echex (Mt_rand (0,15)); } $_session["Code" = $_ ...