PHP图片验证码类
来源:互联网 发布:淘宝卡密提取网址 编辑:程序博客网 时间:2024/05/23 15:37
<?phpclass Imagecode{private $width,$height,$str;//宽、高、随机字符function __construct($width=120,$height=30,$str="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"){$this->width=$width;$this->height=$height;$this->str=$str;}function creatimg(){return imagecreate($this->width,$this->height);}function random($len=4) //随机数{$str = substr(str_shuffle($this->str),0,$len);//取4个字符$this->strout=$str;}function setbackground($img){$background_color=imagecolorallocate($img,255,255, 255);$border_color=imagecolorallocate($img, 41,163,238);$color = ImageColorAllocate($img, 0,0,0);imagefill($img,0, 0, $background_color);//背景、白色imagerectangle($img, 0, 0, $this->width-1, $this->height-1, $border_color);//边框$w=$this->width/2-18;$h=$this->height/2-7;imagestring($img,12,$w,$h,$this->strout, $border_color);//字位置for($i=1;$i<3;$i++){//$line_color = imagecolorallocate($img,rand(0,255),rand(0,255),rand(0,255));//随机颜色//imageline($img,1,$i,47,$i,$line_color);//固定 位置画线//imagesetpixel($img,mt_rand(0, $width) ,mt_rand(0,$height), $line_color); //画点imageline($img,rand($w,30),rand($h,21),rand($w+20,50),rand($h,21),$border_color); //随机位置画线}}function imgout(){$img=$this->creatimg();$this->random();$this->setbackground($img);imagepng($img);imagedestroy($img);$_SESSION["code"] = $this->strout ;session_destroy();}}@header("Content-Type:image/png");session_start();$img=new Imagecode(50,20);$img->imgout();?>
PHP图片验证码
效果:
0 0
- php图片验证码类
- PHP图片验证码类
- PHP图片验证码
- php 图片验证码
- php 图片验证码
- php图片验证码
- 【PHP】图片验证码
- php 图片验证码
- php验证码--图片
- php 图片验证码
- PHP图片类(验证码,水印,缩略)
- php图片验证码技术
- php生成图片验证码
- php 验证码图片看不到
- php生成图片验证码
- php生成验证码图片
- PHP生成图片验证码
- PHP实现图片验证码
- 微软降低WP授权费 ,华为,索尼等手机厂商伸出橄榄枝
- Solr4 + Jcseg 数据导入
- Linux I2C驱动分析与实现
- 一生必读经典书籍大全
- mysql 5.0存储过程学习总结
- PHP图片验证码类
- 2014,期待中兴firefox os手机
- c++读取目录下所有文件名
- 从时间服务器获取时间(linux) + Objective-C将获取的值转化为NSDate
- Android 中自定义控件和属性(attr.xml,declare-styleable,TypedArray)的方法和使用
- 使window.open() 全兼容IE, Firefox, Chrome的最新写法
- SQL*Net more data from client
- 关于4G的一些小秘密
- 基于arcgis model转换CAD至SHP,实现注记到多边形字段传递