最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php實(shí)現(xiàn)加減法驗(yàn)證碼代碼

 更新時(shí)間:2014年02月14日 10:51:39   作者:  
這篇文章主要介紹了php實(shí)現(xiàn)的加減法驗(yàn)證碼代碼,可以使用10以內(nèi)的加減法生成圖片,需要的朋友可以參考下

復(fù)制代碼 代碼如下:

<?php
/*圖片驗(yàn)證碼文件,加減計(jì)算方式*/

class ImageCode{

 private $Jiashu  = 0;        //加數(shù)或者減數(shù)
 private $JianShu = 0;        //被加數(shù)或者被減數(shù)
 private $YunSuan = '';       //運(yùn)算符
 private $DeShu   = 0;        //得數(shù)
 private $String  = '';       //字符串樣式
 private $Img;                //圖片對(duì)象
 private $Width   = 100;      //圖片寬度
 private $Height  = 50;       //圖片高度
 private $Ttf     = 'Num.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 = 'Num.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);
 }

}

$ImageCode = new ImageCode;
$ImageCode -> Show(130, 35, 'Num.ttf', 'code');

相關(guān)文章

最新評(píng)論

彭阳县| 根河市| 庐江县| 大余县| 黑山县| 平阴县| 象州县| 渑池县| 霍邱县| 时尚| 蓝田县| 大关县| 富源县| 竹北市| 大新县| 平顶山市| 大关县| 伽师县| 乐陵市| 贵阳市| 大余县| 高雄市| 临夏市| 罗定市| 江源县| 信宜市| 丁青县| 克拉玛依市| 谷城县| 灵寿县| 德令哈市| 汽车| 太白县| 商城县| 宁国市| 兴国县| 万载县| 滦南县| 泗阳县| 水城县| 夏河县|