搜索热词
感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编来看看吧。
经测试代码如下:
/**
* 建立英文数字验证码
*
* @param
* @author 编程之家 jb51.cc jb51.cc
**/
public function buildImageVerify(){
$image = imagecreate($width,$height);
$r = Array(225,255,223);
$g = Array(225,236,237,255);
$b = Array(225,166,125);
$keys = mt_rand(0,3);
$bg = imagecolorallocate($image,$r[$keys],$g[$keys],$b[$keys]);//背景色
$border = imagecolorallocate($image,100,100);
$stringColor = imagecolorallocate($image,mt_rand(0,200),120),120));
for ($i = 0; $i < 25; $i++) {
imagesetpixel($image,$width),$height),$stringColor);
}
for($i=0;$i<4;$i++){
$rand = dechex(mt_rand(0,15));
$num.=$rand;
imagestring($image,5,$i*10+5,mt_rand(1,8),$rand,$stringColor);
}
$_SESSION['verify'] = md5($num);
$this->out($image,$type);
}
总结
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。