PHP code example of yonghua4413 / captcha

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

    

yonghua4413 / captcha example snippets



use Yonghua4413\captcha;

// 验证码配置
$config = [
    'type'      => 1, // 验证码类型(默认1) [1-字母数字, 2-算术, 3-中文]
    'width'     => 150, // 图片宽度(必填)
    'height'    => 80, // 图片高度(必填)
    'length'    => 4, // 验证码位数(默认5)
    'fontSize'  => 25, // 字体大小(默认25)
    'gif'       => 30, // 使用动图(默认30) [0-不启用,其他大于0的数字为gif帧速度]
    'uppercase' => 0, // 区分大小写(默认0) [0不区分,1区分]
    'session'   => 'demo' // session key $_SESSION['demo']['captcha']
];
// 输出图片
Captcha::create($config);

// 验证验证码
Captcha::check('验证码字符','demo');