Yii----验证码

captche文件下:两个类在内部有结合
CCaptcha.php #form表单使用 $this -> widget('CCaptcha');  会间接调用控制器的方法,路由:user/captcha
CCaptchaActive.pp #控制器使用 生成验证码的核心类(有更新文件)


//验证码控制器,被actions访问的类都要继承CActive
		function actions(){	
			return array(
				'captcha'=>array(
					//此class = http://www.yii.com/index.php?r=user/captcha/	可以看到验证码
					'class'=>'system.web.widgets.captcha.CCaptchaAction',   //有更新文件(=framework/web/widgets/captcha/CCaptchaAction)
					'width'=>75,
					'height'=>30,
				),
				
				//以下为测试用:我们在外边随便定义一个类,都可以通过这种方式访问
				// user/coo 就会访问Computer.php里边的run()方法
				'coo'=>array(
					'class'=>'application.controllers.Computer',	#别名application代表protected目录
				),
			);
		}
					claas Computer extends CActive{ function run(){ echo 'computer start..'; }}


登录模型
array('verifyCode','captcha','message'=>'请输入正确的验证码'), #captcha会找到CcaptchaAction进行验证码的比较。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值