问题描述
- PHP做了一个验证码,之前一直好好的,但突然就用不了了,加载不出来了!
-
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库是开了的啊!
解决方案
这些代码看不出问题,而且你也说了,原来好好的,你没有修改代码。
贴出你遇到的错误,检查是不是配置的问题。
时间: 2024-08-04 00:26:43