您好,欢迎访问一九零五行业门户网

php编写生成酷炫验证码 yii2 验证码 验证码 php 图片 php验证码不显

1 php 2$im=imagecreate(200,100);//生成画布 3 imagecolorallocate($im,0,0,0);//背景色 4$white=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));//生成随机颜色 5for($i=0;$i$i++) 6{ 7 imageline($im,rand(0,200),rand(0,100),rand(0,200),rand(0,100),$white);//生成干扰线条元素 8} 9for($i=0;$i$i++)10{11 imagesetpixel($im,rand(0,200),rand(0,100),$white);//生成干扰点元素12}13for($i=0,$str='';$i$i++)//通过循环获得四个字符14{15switch(rand(1,3))16 {17case'1':18$ch=rand(0,9);19break; 20case'2':21$ch=sprintf('%c',rand(97,122));22break;23case'3':24$ch=sprintf('%c',rand(65,90));25break;26 }27$str.=$ch;2829}30 imagettftext($im,32,rand(0,15),55,70,$white,'c.ttc',$str);//在画布上输出字符串31header(content-type:image/jpeg);32 imagejpeg($im);33 imagedestroy($im);34 ?>
以上就介绍了php编写生成酷炫验证码,包括了验证码,php方面的内容,希望对php教程有兴趣的朋友有所帮助。
其它类似信息

推荐信息