首页 / PHP / php实现验证码制作
php实现验证码制作
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php实现验证码制作,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1133字,纯文字阅读大概需要2分钟。
内容图文
先给看下 大致的效果那么接下来的就直接贴代码吧
php $image = imagecreatetruecolor(100, 30); //创建画布$imagecolor = imagecolorallocate($image, 255, 255, 255); //背景色 imagefill($image, 0, 0, $imagecolor); //填充背景色for($i=0;$i<4;$i++ ){ //循环4位数$fontsize = 6; $fontcolor = imagecolorallocate($image, rand(0, 200), rand(0, 200), rand(0, 200)); $fontcontent = rand(0, 9); $x = $i*100/4 + rand(5, 15); $y = rand(5, 10); imagestring($image, $fontsize, $x, $y, $fontcontent, $fontcolor); } for($i=0;$i<200;$i++ ){ //循环 添加干扰点$pointcolor = imagecolorallocate($image, rand(50, 200), rand(50, 200), rand(50, 200)); $x = rand(1, 99); $y = rand(1, 29); imagesetpixel($image, $x, $y, $pointcolor); } for($i=0;$i<3;$i++){ //循环 添加干扰线 $linecolor = imagecolorallocate($image, rand(100, 250), rand(100, 250), rand(100, 250)); $x1 = rand(1, 25); $x2 = rand(50, 75); $y1 = rand(1, 15); $y2 = rand(15, 25); imageline($image, $x1, $y1, $x2, $y2, $linecolor); } header("content-type:image/png"); imagepng($image); imagedestroy($image); ?>
以上就介绍了php 实现验证码制作,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
内容总结
以上是互联网集市为您收集整理的php实现验证码制作全部内容,希望文章能够帮你解决php实现验证码制作所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。