加减 验证码
来源:互联网 发布:曼威网络 编辑:程序博客网 时间:2024/05/18 03:23
调用 // 注用TP时, 1.ttf放在根目录下 1.tff为yahoo字体
include "ImageCode.class.php";$show = new \ImageCode();$show->show(130, 35, '1.ttf', 'code');
外部类
<?php/*图片验证码文件,加减计算方式*/class ImageCode{ private $Jiashu = 0; //加数或者减数 private $JianShu = 0; //被加数或者被减数 private $YunSuan = ''; //运算符 private $DeShu = 0; //得数 private $String = ''; //字符串样式 private $Img; //图片对象 private $Width = 100; //图片宽度 private $Height = 50; //图片高度 private $Ttf = '1.ttf';//字体文件 private $Session = 'code'; //Session变量 private function JiaShu(){ header('Content-type:image/png'); $this -> Jiashu = rand(1, 10); $this -> JianShu = rand(1, 10); $this -> YunSuan= $this -> Jiashu > $this -> JianShu ? '-' : '+'; $this -> DeShu = $this -> Jiashu > $this -> JianShu ? $this -> Jiashu - $this -> JianShu : $this -> Jiashu + $this -> JianShu; } public function Show( $W = 100, $H = 50, $T = '1.ttf', $Code = 'code' ){ $this -> JiaShu(); $this -> String = $this -> Jiashu . $this -> YunSuan . $this -> JianShu . '= ? '; $this -> Width = $W; $this -> Height = $H; $this -> Ttf = $T; $this -> Session= $Code; session_start(); $_SESSION[$this -> Session] = $this -> DeShu; $this -> Images(); } private function Images(){ $this -> Img = imagecreate($this -> Width, $this -> Height); $background_color = imagecolorallocate ($this -> Img, 255, 255, 255); imagecolortransparent($this -> Img, $background_color); imagettftext($this -> Img, 14, 0, 1, 20, imagecolorallocate ($this -> Img, 0, 0, 0), $this -> Ttf, $this -> String ); $this -> EchoImages(); } private function EchoImages(){ imagepng($this -> Img); imagedestroy($this -> Img); }}
0 0
- 加减 验证码
- 自用 验证码 带一二三加减
- 验证码(随机数字+字符,数字加减)
- PHP生成加减算法方式的验证码
- 原码反码补码加减运算
- 原码、反码、补码之加减运算
- JavaScript商城购物车结算/收货/小计和加减/表单验证
- 原码、补码、运算(加减、异或)实例
- 日期加减
- 加减人生
- 指针加减
- 日期加减
- 各种加减
- 位加减
- 时间加减
- 复数加减
- 加减运算
- 日期加减
- 学习设计模式——工厂方法
- hdu 1879 继续畅通工程
- 28-反射机制-03-反射机制(获取Class对象的三种方式)
- 杭电1102Constructing Roads
- NOIP2014 无线网路发射器选址
- 加减 验证码
- 在Linux系统下重启Oracle服务
- (原创)ios提示用户去AppStore好评逻辑
- Truck History POJ 1789【Kruscal算法 || Prim】
- 源码 、补码、 反码的详解(转载)
- 黑马程序员——Java中集合框架总结
- Second Day
- Android基础篇之Service(二) - Service声明周期周期
- IP协议解读(二)