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
PHP实现图片验证码【加减乘除】
最新推荐文章于 2021-04-27 09:15:10 发布
本文详细介绍了如何使用PHP生成包含加减乘除算术题目的图片验证码,涉及图像处理、随机数生成及算术运算,旨在增强验证码的安全性,防止自动化机器人攻击。
摘要由CSDN通过智能技术生成