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)){ //验证失败 };
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
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
25Jul2016
Example of php verification code (GD library generates verification code)
24Nov2017
There are many image verification code libraries available in Laravel. This article introduces one of them: gregwar/captcha. This library is relatively simple and commonly used in Laravel.
11May2023
With the development of the Internet, more and more websites need to use verification codes to prevent malicious registration, crawlers and other behaviors. Image verification code is a common form of verification code. It displays an image containing random characters or numbers, allowing users to enter the correct verification code before proceeding to the next step. This article will introduce how to use PHP and GD library to generate image verification codes. The GD library is an image processing library that can be used to generate, process and manipulate various image formats. PHP already has a built-in GD library and provides many functions for creating and manipulating graphs
25Jul2016
Example of generating verification code by php GD library
12Jul2023
How to create a dynamic image verification code using PHP and GD library In web applications, in order to prevent bots and malicious attackers from automating operations, verification codes are often used, requiring users to enter a verification code to confirm their identity. By using PHP and GD library, we can easily create dynamic image verification codes. The GD library is an extension library for PHP that provides some functions for processing images. In this article, we will use the functions of the GD library to generate an image containing random characters and present it to the user as a verification code. No.
Hot Tools
PHP dynamically randomly generates verification code class
PHP dynamically randomly generates verification code class
Simple and easy-to-use PHP verification code class
Simple and easy-to-use PHP verification code class
A PHP verification code generation code
A PHP verification code generation code