php生成酷炫的四个字符验证码
网络编程 2021-07-05 09:10www.168986.cn编程入门
可以生成随机颜色、干扰线条元素、干扰点元素的php验证码,这篇文章主要介绍了php生成酷炫的四个字符验证码的编写方法,感兴趣的小伙伴们可以参考一下
本文实例为大家分享php生成验证码的实现代码,供大家参考,具体内容如下
<?php $im=imagecreate(200,100);//生成画布 imagecolorallocate($im,0,0,0);//背景色 $white=imagecolorallocate($im,rand(0,255),rand(0,255),rand(0,255));//生成随机颜色 for($i=0;$i<9;$i++) { imageline($im,rand(0,200),rand(0,100),rand(0,200),rand(0,100),$white);//生成干扰线条元素 } for($i=0;$i<150;$i++) { imagesetpixel($im,rand(0,200),rand(0,100),$white);//生成干扰点元素 } for($i=0,$str='';$i<4;$i++)//通过循环获得四个字符 { switch(rand(1,3)) { case'1': $ch=rand(0,9); break; case'2': $ch=sprintf('%c',rand(97,122)); break; case'3': $ch=sprintf('%c',rand(65,90)); break; } $str.=$ch; } imagettftext($im,32,rand(0,15),55,70,$white,'c.ttc',$str);//在画布上输出字符串 header("Content-type:image/jpeg"); imagejpeg($im); imagedestroy($im); ?>
以上就是本文的全部内容,希望对大家学习PHP程序设计有所帮助。
上一篇:利用php输出不同的心形图案
下一篇:ThinkPHP连接Oracle数据库
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程