进击的码农

一个好用的图形验证码类

github地址:https://github.com/Gregwar/Captcha

$uuid = $this->checkParam('uuid', 'GET');
$phrase = 'abcdefghkmnpstuwx23456789ABCDEFGHKMNPRSTUWXY';
$chars = str_split($phrase);
$str = '';
for ($i = 0; $i < 4; $i++) {
    $str .= $chars[array_rand($chars)];
}
$redis = Redis::getRedis(13);
$redis->setex('code_' . $uuid, 60, $str);
header('Content-type: image/jpeg');
$builder = new CaptchaBuilder($str);
$builder->build(120);
$builder->output();

回复

This is just a placeholder img.