具体如下:
1、配置文件中增加验证码配置
'captcha' => [ // 验证码字符集合 'codeSet' => '23456789', // 验证码字体大小(px) 'fontSize' => 25, // 是否画混淆曲线 'useCurve' => false, // 验证码位数 'length' => 4, // 验证成功后是否重置 'reset' => true ],
2、后端验证码方法写入
public function check($code='')
{
if (!captcha_check($code)) {
$this->error('验证码错误');
} else {
return true;
}
}3、前端调用验证码 并设置onclick属性,点击图片刷新验证码
请输入验证码![]()