private $Jiashu = 0; //加數或者減數 private $JianShu = 0; //被加數或者被減數 private $YunSuan = ''; //運算 " /> 中文字幕综合,忘忧草在线日韩www影院,成人欧美一区二区三区视频网页

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

php實現加減法驗證碼代碼

復制代碼 代碼如下:
<?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     = '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');

php技術php實現加減法驗證碼代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 锦州市| 新乡县| 平舆县| 盖州市| 洛扎县| 泸定县| 拜泉县| 汝州市| 克东县| 易门县| 绥中县| 马龙县| 来安县| 肥东县| 开封市| 修文县| 鸡东县| 鄄城县| 肇庆市| 蓬莱市| 白朗县| 资阳市| 天等县| 伽师县| 红安县| 阳高县| 乐亭县| 兴文县| 邯郸县| 中山市| 香格里拉县| 宿迁市| 宜州市| 新民市| 拉孜县| 成都市| 屏山县| 衡山县| 怀化市| 波密县| 郓城县|