function verifyImg($width=80,$height=30){
//定义画布
$img=imagecreatetruecolor($width, $height);
//定义颜色
$white=imagecolorallocate($img, 255, 255, 255);
$black=imagecolorallocate($img, 0, 0, 0);
//画出画布
imagefilledrectangle($img, 1, 1, $width-2, $height-2, $white);
//写字
$size=mt_rand(18,22);
$angle=mt_rand(-3,3);
$x=mt_rand(2,10);
$y=mt_rand(20,28);
$fontfiles='../font/simhei.ttf';
$_SESSION['verify']=$str=randomStr();
imagettftext($img, $size, $angle, $x, $y, $black,$fontfiles ,$str);
//增加干扰点
for($i=0;$i<100;$i++){
$x=mt_rand(1,$width-1);
$y=mt_rand(1,$height-1);
$red=mt_rand(1,150);
$green=mt_rand(1,150);
$blue=mt_rand(1,150);
$color=imagecolorallocate($img, $red, $green, $blue);
imagesetpixel($img, $x, $y, $color);
}
//生成图片
header("content-type:image/gif");
imagegif($img);
imagedestroy($img);
请大神帮小弟看看是哪里出了问题了!
搞得我毫无头绪!
之前一直用得好好的,突然间就用不了了!
GD库是开了的啊!