04-09
                                0
                            
                            thinkphp 之 captcha 验证码
1.安装
composer require topthink/think-captcha 1.* -vvv2.html
<img id="captcha" src="{:captcha_src()}" class="verify" onclick="resVerify()" alt="验证码" />
 <a href="javascript:resVerify();">看不清,换一张</a>
<input type="text" name="verify" class="pass-text-input " placeholder="请输入验证码">
<script>
       function resVerify(){
         document.getElementById("captcha").src = "{:captcha_src()}?time=" + Math.random();
       }
</script>
     3.php
$validate=new Validate([
      'verify|验证码'=>'require|captcha',
      ]);
$verify=input('verify');
 if (!$validate->check($data)) {
          return ['msg'=>$validate->getError()];
 } 
                            