public function getImgVerify(){
ob_end_clean();
$im = imagecreatetruecolor( 150 ,50 );
$white = imagecolorallocate( $im , 255 , 255 ,255);
$grey = imagecolorallocate($im ,0 , 0,0);
$black = imagecolorallocate($im , rand(1,255) , rand(1,255) , rand(1,255));
imagefill($im,0,0,$grey);
$rand = rand( 1 , 4);
$one = rand( 1 ,9);
$two = rand(1 ,9);
if( $rand == 1){
$result = $one + $two;
$text = $one . "+" . $two . "=?";
}else if( $rand == 2){
if($one < $two){
list( $two , $one) = [ $one ,$two];
}
$result = $one - $two;
$text = $one . "-" . $two . "=?";
}else if( $rand == 3){
$result = $one * $two;
$text = $one . "*" . $two . "=?";
}else if($rand == 4){
$res = $one * $two ;
$result = $res / $one ;
$text = $res . "/" . $one . "=?";
}
session_start();
$_SESSION['vcode'] = $result;
$font = './ArvoRegular.ttf';
$i =
PHP实现图片验证码【加减乘除】
最新推荐文章于 2021-04-27 09:15:10 发布
本文详细介绍了如何使用PHP生成包含加减乘除算术题目的图片验证码,涉及图像处理、随机数生成及算术运算,旨在增强验证码的安全性,防止自动化机器人攻击。

最低0.47元/天 解锁文章
257

被折叠的 条评论
为什么被折叠?



