TP5.+的扩展

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Lg632/article/details/81942488

安装验证码扩展包:

composer require topthink/think-captcha

在模板里可以正常使用验证码了,模板里输出验证码
    <div>{:captcha_img()}</div>
或者
    <div><img src="{:captcha_src()}" alt="captcha" /></div>

控制器里验证,使用TP5的内置验证功能即可

    $this->validate($data,[
        'captcha|验证码'=>'require|captcha'
    ]);

或者手动验证

    if(!captcha_check($captcha)){
        //验证失败
    };

猜你喜欢

转载自blog.csdn.net/Lg632/article/details/81942488
tp5