当前位置 : 主页 > 网络编程 > PHP >

php生成各种验证码

来源:互联网 收集:自由互联 发布时间:2021-06-28
index.html 1、数字验证码 验证码: 2、数字+字母验证码 验证码: 3、中文验证码 验证码: 4、仿google验证码 验证码: 5、算术验证码 验证码: code.php =0 ) { imagesetpixel ($distortion_im, (int)($
index.html

 
    
   
   

1、数字验证码

验证码:

2、数字+字母验证码

验证码:

3、中文验证码

验证码:

4、仿google验证码

验证码:

5、算术验证码

验证码:

code.php
 =0 ) {
    imagesetpixel ($distortion_im, (int)($i+10+sin($j/$im_y*2*M_PI-M_PI*0.1)*4) , $j , $rgb);
}
}
}
//加入干扰象素;
$count = 160;//干扰像素的数量
for($i=0; $i<$count; $i++){
$randcolor = ImageColorallocate($distortion_im,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
imagesetpixel($distortion_im, mt_rand()%$im_x , mt_rand()%$im_y , $randcolor);
}

$rand = mt_rand(5,30);
$rand1 = mt_rand(15,25);
$rand2 = mt_rand(5,10);
for ($yy=$rand; $yy<=+$rand+2; $yy++){
for ($px=-80;$px<=80;$px=$px+0.1)
{
$x=$px/$rand1;
    if ($x!=0)
    {
    $y=sin($x);
    }
    $py=$y*$rand2;

    imagesetpixel($distortion_im, $px+80, $py+$yy, $text_c);
}
}

	//设置文件头;
	Header("Content-type: image/JPEG");

//以PNG格式将图像输出到浏览器或文件;
ImagePNG($distortion_im);

//销毁一图像,释放与image关联的内存;
ImageDestroy($distortion_im);
ImageDestroy($im);
}

function make_rand($length="32"){//验证码文字生成函数
	$str="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	$result="";
	for($i=0;$i<$length;$i++){
	$num[$i]=rand(0,25);
	$result.=$str[$num[$i]];
}
	return $result;
}

?>
check_code.php
网友评论