PHP code example of laoshifu / think-captcha

1. Go to this page and download the library: Download laoshifu/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/ */

    

laoshifu / think-captcha example snippets


use laoshifu\captcha\facade\Captcha;

// 生成验证码图片
return Captcha::create();

// 生成算术验证码
return Captcha::create('math');

use laoshifu\captcha\facade\Captcha;

// 验证用户输入
if (Captcha::check($code)) {
    // 验证成功
}

return [
    // 验证码字符集
    'codeSet' => '2345678abcdefhijkmnpqrstuvwxyzABCDEFGHJKLMNPQRTUVWXY',
    // 验证码长度
    'length' => 4,
    // 验证码字体大小
    'fontSize' => 25,
    // 是否使用中文验证码
    'useZh' => false,
    // 是否使用算术验证码
    'math' => false,
    // 验证码图片宽度
    'imageW' => 220,
    // 验证码图片高度
    'imageH' => 60,
];