1.页面端引入
{:captcha_img()}
或者
<img src="{:captcha_src()}" alt="">
点击自动刷新
<img src="{:captcha_src()}" alt="" onclick="this.src='{:captcha_src()}' ">
2.控制器接收并验证
// 验证验证码
if (captcha_check($data['valicode'])) {
$this->success("验证码正确");
}else{
$this->error("验证码错误");
}
3.自定义配置项 C:\xampp\htdocs\tp\tp5\application 下的config.php文件末尾追加
//分页配置
...
// 应用配置:验证码
'captcha' => [
/*验证码字符集合*/
'codeSet' => '123456789',
/*切换为中文验证码*/
'useZh' => true,
/*中文验证字符集合*/
'zhSet' => '你好',
/*验证码的位数*/
'length