u014539311 2016-02-22 15:36 采纳率: 0%
浏览 1626

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库是开了的啊!

  • 写回答

1条回答

  • threenewbee 2016-02-22 23:15
    关注

    这些代码看不出问题,而且你也说了,原来好好的,你没有修改代码。

    贴出你遇到的错误,检查是不是配置的问题。

    评论

报告相同问题?

悬赏问题

  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 vue2登录调用后端接口如何实现