這里寫描述
使用算數(shù)的時候 加號和等于符號部分字體加載不正常
/**
* 驗證碼
*/
public function verifyImg($hashid = '0000', $math = false)
{
$builder = new CaptchaBuilder(); // 初始化驗證碼類
$builder->setBackgroundColor(255, 255, 255);
if ($math) {
$x = random_int(10, 30);
$y = random_int(1, 9);
$phrase = "{$x} + {$y} = ";
$builder->setPhrase($phrase);
$result = $x + $y;
}
$builder->setDistortion(false);
$builder->setMaxBehindLines(0);
$builder->setMaxFrontLines(0);
$builder->build(); // 生成驗證碼
Cache::set('captcha_' . $hashid, $math ? $result : strtolower($builder->getPhrase()), 900); // 緩存驗證碼數(shù)據(jù)
$img_content = $builder->get(); // 獲得驗證碼圖片二進(jìn)制數(shù)據(jù)
return response($img_content, 200, ['Content-Type' => 'image/jpeg']); // 輸出驗證碼二進(jìn)制數(shù)據(jù)
}