增加支持验证码图片点击自动更换
thinkphp5 验证码类库
composer require topthink/think-captcha
<div>{:captcha_img()}</div>
或者
<div><img src="{:captcha_src()}" alt="captcha" /></div>
上面两种的最终效果是一样的
或者带有点击图片自动更换验证码的功能
<div>{:captcha_img_with_replacement()}</div>
使用TP5的内置验证功能即可
$this->validate($data,[ 'captcha|验证码'=>'require|captcha' ]);
或者手动验证
if(!captcha_check($captcha)){ //验证失败 };