PHP code example of hectorqin / think-captcha

1. Go to this page and download the library: Download hectorqin/think-captcha library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hectorqin / think-captcha example snippets


class CaptchaController
{
    public function index($id = "", $configName = "")
    {
        $captcha = new Captcha(); // 可传入数组配置进行覆盖<优先级最高>
        return $captcha->entry($id, $configName); // 可选择配置模式
    }
}

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

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