首页 > Web开发 > 详细

PHP验证码

时间:2015-09-12 22:16:08      阅读:388      评论:0      收藏:0      [点我收藏+]
验证码刷新
<?php $img=imagecreate(50, 20); //创建画布 $color=imagecolorallocate($img, 0, 0, 0); //创建背景颜色 $font=imagecolorallocate($img, 255, 255, 255);//创建文本颜色 $point=imagecolorallocate($img,rand(0, 255),rand(0, 255),rand(0, 255)); //点的颜色 $line=imagecolorallocate($img, rand(0, 100), rand(0, 125), rand(0, 255)); imagefill($img, 0,0, $color); //区域填充 $string=range(‘a‘,‘z‘); $s=""; for($i=0;$i<4;$i++){ //循环4个字符 $rand=mt_rand(0,25 ); //从1到最大开始循环 $s.=$string[$rand]; // } for($i=0;$i<100;$i++){ $x=rand(0,50); $y=rand(0, 20); imagesetpixel($img, $x, $y, $point); } imageline($img, 0,25,50,10,$line); session_start(); $_SESSION[‘code‘]=$s; imagestring($img, 5,5, 3, $s, $font); header("content-type:image/png"); imagepng($img);

 

PHP验证码

原文:http://www.cnblogs.com/mengluo/p/4803693.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!