PHP code example of lovefc / captcha
1. Go to this page and download the library: Download lovefc/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/ */
lovefc / captcha example snippets
`
/* 实例化 */
$ver = new FC\Captcha();
/* 验证码的一些设置 */
// 验证码宽度
$ver->width = 300;
// 验证码高度
$ver->height = 100;
// 验证码个数
$ver->nums = 4;
// 随机字符串
$ver->random = '舔狗不得好死';
// 随机数大小
$ver->font_size = 40;
// 干扰线数量,为0时没有干扰线
$ver->interfere_line = 50;
// 字体路径
//$ver->font_path = __DIR__.'/Font/zhankukuhei.ttf';
// 是否为动态验证码
//$ver->is_gif = true;
// 动图帧数
//$ver->gif_fps = 10;
/* 生成验证码 */
$code = $ver->getCode();
/*
$_SESSION['code'] = $code
....(这里自己存Session或者Redis)
*/
/* 生成验证码图片 */
$ver->doImg($code);