search
HomePHP LibrariesVerification code librarythinkphp5 verification code library

think-captcha

thinkphp5 verification code library

Install

composer require topthink/think-captcha

use

Output the verification code in the template

<div>{:captcha_img()}</div>

or

<div><img src="{:captcha_src()}" alt="captcha" /></div>
上面两种的最终效果是一样的

Verify in the controller

Just use TP5’s built-in verification feature

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

Or verify manually

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

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

Use GD library to do verification code in php, phpgd library verification code_PHP tutorialUse GD library to do verification code in php, phpgd library verification code_PHP tutorial

12Jul2016

In php, GD library is used for verification code, and phpgd library is used for verification code. Use GD library to do verification code in php, phpgd library verification code php require_once 'string.func.php';//Use GD library to do verification code/** *Add verification text* @param int $type * @param int $length */function

Easily implement verification code function: Use Composer to install the lsmverify/lsmverify libraryEasily implement verification code function: Use Composer to install the lsmverify/lsmverify library

18Apr2025

I encountered a common but difficult problem when developing a user registration and logging into a system: how to effectively prevent robots from automatically registering and logging in. I tried multiple verification methods, but it didn't work well until I discovered this powerful PHP verification code library of lsmverify/lsmverify. By using Composer to install and configure this library, I successfully implemented efficient verification code function in the project, greatly improving the security of the system.

Simple verification code generation, simple verification code generation_PHP tutorialSimple verification code generation, simple verification code generation_PHP tutorial

12Jul2016

Simple verification code generation, simple verification code generation. Simple verification code generation, simple verification code generation for($i= 0;$i 5;$i ){ $rand .= dechex( rand( 1, 15)); // Random number hexadecimal 1-F generation 5} $im = imagecreatetruecolor (100, 30)

Zend Framework generates verification codes and implements verification code verification functions (with demo source code download), zenddemo_PHP tutorialZend Framework generates verification codes and implements verification code verification functions (with demo source code download), zenddemo_PHP tutorial

12Jul2016

Zend Framework generates verification codes and implements verification code verification functions (with demo source code download), zenddemo. Zend Framework generates verification codes and implements verification code verification functions (with demo source code download), zenddemo This article describes how Zend Framework generates verification codes and implements verification code verification functions.

Simple and safe PHP verification code with calling method, PHP verification code with calling_PHP tutorialSimple and safe PHP verification code with calling method, PHP verification code with calling_PHP tutorial

12Jul2016

Simple and secure PHP verification code with calling method, PHP verification code with calling method. Simple and secure PHP verification code with calling method, PHP verification code with call. 1. Verification code example 2. PHP verification code class, secoder.class.php php /** * Security verification code * * Secure verification

PHP implementation is suitable for custom verification code classes, php verification codePHP implementation is suitable for custom verification code classes, php verification code

06Jul2016

PHP implementation is suitable for custom verification code classes, php verification code. PHP implementation is suitable for custom verification code classes, php verification code. The example of this article shares the PHP verification code class for everyone, and uses objects to implement the verification code class for your reference. The specific content is as follows

See all articles