PHP头条
热点:

一个自己写的10以内的加减法验证码-PHP源码


一个自己写的10以内的加减法验证码

 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');

以上就是一个自己写的10以内的加减法验证码的内容,更多相关内容请关注PHP中文网(www.php1.cn)!

www.phpzy.comtrue/phpyy/45077.htmlTechArticle一个自己写的10以内的加减法验证码-PHP源码 一个自己写的10以内的加减法验证码 Jiashu = rand(1, 10);$this -> JianShu = rand(1, 10);$this -> YunSuan= $this -> Jiashu > $this -> JianShu ? - : +;$this -> DeShu = $thi...

相关文章

PHP之友评论

今天推荐