码迷,mamicode.com
首页 > 其他好文 > 详细

Yii2验证码使用教程

时间:2018-11-17 16:16:16      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:ons   set   代码   max   添加   使用   captcha   aac   设置   

控制器代码


public function actions()
    {
        return [
            'captcha' => [
                'class' => 'yii\captcha\CaptchaAction',
                'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
                'maxLength' => 4, //最大显示个数
                'minLength' => 4,//最少显示个数
                'height' => 42,//高度
                'width' => 120,  //宽度
                'offset' => 10, //设置字符偏移量 有效果
                'foreColor' => 0x000000,
            ]
        ];
    }

模型代码
在rules方法中添加如下一行


['captcha', 'captcha','captchaAction'=>'/rbac/user/captcha'],

注意captchaAction这个属性指向我们上面在控制中定义的captcha这个action。

原文地址:https://segmentfault.com/a/1190000016175213

Yii2验证码使用教程

标签:ons   set   代码   max   添加   使用   captcha   aac   设置   

原文地址:https://www.cnblogs.com/lalalagq/p/9973676.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!