标签:
<!--vcode.class.php内容-->
<?php
	class Vcode {
		private $width;    //宽
		private $height;   //高
		private $num;	   //数量
		private $code;    //验证码
		//构造方法, 三个参数
		function __construct($width, $height, $num) {
			$this->width = $width;
			$this->height = $height;
			$this->num = $num;
			$this->code = $this->createcode(); //调用自己的方法
		}
		//获取字符的验证码, 用于保存在服务器中
		function getcode() {
			return $this->code;
		}
		//输出图像
		function outimg() {
			//创建背景 (颜色, 大小, 边框)
			$this->createback();
//画字 (大小, 字体颜色)
			//干扰元素(点, 线条)
			
			//输出图像
		}
		//创建背景
		private function createback() {
		
		}
		//画字
		private function outstring() {
		
		}
		//设置干扰元素
		private function setdisturbcolor() {
		
		}
		//输出图像
		private function printimg() {
			
		}
		//生成验证码字符串
		private function createcode() {
			$codes = "3456789abcdefghijkmnpqrstuvwxyABCDEFGHIJKLMNPQRSTUVWXY";
$code = "";
			for($i=0; $i < $this->num; $i++) {
				//返回随机字符
				$code .=$codes{rand(0, strlen($codes)-1)};	
			}
			return $code;
		}
}
标签:
原文地址:http://www.cnblogs.com/webforward/p/5418698.html