ilbsfx / captcha
此包最新版本(v1.0)没有可用的许可信息。
tp验证码独立版本
v1.0
2021-06-09 06:55 UTC
This package is not auto-updated.
Last update: 2024-09-26 14:29:14 UTC
README
tp验证码独立版
安装
composer require ilbsfx/captcha
配置参数(可选)
使用
use Colton\Captcha\CaptchaBuilder; //(可选参数) $config = [ //验证码位数 'length' => 5, // 验证码字符集合 'codeSet' => '2345678abcdefhijkmnpqrstuvwxyzABCDEFGHJKLMNPQRTUVWXY', // 是否使用中文验证码 'useZh' => false, // 是否使用算术验证码 'math' => false, // 是否使用背景图 'useImgBg' => false, //验证码字符大小 'fontSize' => 25, // 是否使用混淆曲线 'useCurve' => true, //是否添加杂点 'useNoise' => true, // 验证码字体 不设置则随机 'fontttf' => '', //背景颜色 'bg' => [243, 251, 254], // 验证码图片高度 'imageH' => 0, // 验证码图片宽度 'imageW' => 0 ]; $captcha = new CaptchaBuilder($config); // 获取验证码key $_SESSION['key'] = $captcha->getCodeKey(); // 输出验证码图片 $captcha->output(); // 验证验证码是否正确 $userInput = $_POST['code']; $res = $captcha->check($userInput, $_SESSION['key']); if ($res === true) { // 验证码正确 } else { // 验证码错误 }