Copy CodeThe code is as follows:
/* Picture Verification code file, add and subtract calculation method */
Class imagecode{
Private $Jiashu = 0; Addend or meiosis
Private $JianShu = 0; Summand or Minuend
Private $YunSuan = '; Operator
Private $DeShu = 0; Count
Private $String = '; String style
Private $Img; Picture Object
Private $Width = 100; Picture width
Private $Height = 50; Picture height
Private $TTF = ' num.ttf ';//font file
Private $Session = ' code '; Session variable
Private Function Jiashu () {
Header (' content-type:image/png ');
$this-Jiashu = rand (1, 10);
$this-Jianshu = rand (1, 10);
Jianshu, Jiashu > $this, yunsuan= $this, $this '-' : '+';
$this Deshu = Jiashu > $this, $this, Jianshu? jiashu-$this, $this, Jianshu: $this, Jiashu + $this-Jianshu;
}
Public Function Show ($W = $H =, $T = ' Num.ttf ', $Code = ' Code ') {
$this-Jiashu ();
$this, String = $this, Jiashu. Yunsuan, $this. Jianshu, $this. '= ? ';
$this Width = $W;
$this, Height = $H;
$this, TTF = $T;
$this-session= $Code;
Session_Start ();
$_session[$this, SESSION] = Deshu, $this;
$this-Images ();
}
Private Function Images () {
$this, Img = Imagecreate ($this Width, $this, Height);
$background _color = imagecolorallocate ($this, IMG, 255, 255, 255);
Imagecolortransparent (Img $this, $background _color);
Imagettftext ($this, IMG, 0, 1, imagecolorallocate ($this, IMG, 0, 0, 0), $this, TTF, $this, St Ring);
$this-Echoimages ();
}
Private Function Echoimages () {
Imagepng ($this, IMG);
Imagedestroy ($this, IMG);
}
}
$ImageCode = new Imagecode;
$ImageCode, Show ("Num.ttf", ' Code ');
http://www.bkjia.com/PHPjc/825253.html www.bkjia.com true http://www.bkjia.com/PHPjc/825253.html techarticle Copy the code as follows:? PHP/* Image Verification code file, add and subtract calculation method */class imagecode{Private $Jiashu = 0;//addend or $JianShu = 0;//Summand or minus ...