总结
豆包 AI 助手文章总结

新手求

php中文网
发布: 2016-06-23 14:11:17
原创
981人浏览过

/**
* TestGuest Version1.0
* ================================================
* Copy 2010-2012 yc60
* Web: http://www.yc60.com
* ================================================
* Author: Lee
* Date: 2010-8-13
*/
session_start();
$_rnd_code = 4;
for ($i=0;$i $_nmsg .= dechex(mt_rand(0,15));
}
$_SESSION['code'] = $_nmsg;
$_width = 75;
$_height = 25;
$_img = imagecreatetruecolor($_width,$_height);
$_white = imagecolorallocate($_img,255,255,255);
imagefill($_img,0,0,$_white);
$_flag = false;
if ($_flag) {
$_black = imagecolorallocate($_img,0,0,0);
imagerectangle($_img,0,0,$_width-1,$_height-1,$_black);
}
for ($i=0;$i $_rnd_color = imagecolorallocate($_img,mt_rand(0,255),mt_rand(0,255),mt_rand(0,255));
imageline($_img,mt_rand(0,$_width),mt_rand(0,$_height),mt_rand(0,$_width),mt_rand(0,$_height),$_rnd_color);
}
for ($i=0;$i $_rnd_color = imagecolorallocate($_img,mt_rand(200,255),mt_rand(200,255),mt_rand(200,255));
imagestring($_img,1,mt_rand(1,$_width),mt_rand(1,$_height),'*',$_rnd_color);
}
for ($i=0;$i $_rnd_color = imagecolorallocate($_img,mt_rand(0,100),mt_rand(0,150),mt_rand(0,200));
imagestring($_img,5,$i*$_width/$_rnd_code+mt_rand(1,10),mt_rand(1,$_height/2),$_SESSION['code'][$i],$_rnd_color);
}
header('Content-Type: image/png');
imagepng($_img);
imagedestroy($_img);
?>





我这显示不了验证码,哪里错了新手求指教


回复讨论(解决方案)

将这行 header('Content-Type: image/png'); 注释掉看报什么错了。

Notice: Undefined variable: _nmsg in ...

$_nmsg = ''; //加上这句
for ($i=0;$i $_nmsg .= dechex(mt_rand(0,15));
}


Fatal error: Call to undefined function imagecreatetruecolor() in D:\wamp\www\TestGuest0.9\code.php on line 29
  


这个报错

Notice: Undefined variable: _nmsg in ...

$_nmsg = ''; //加上这句
for ($i=0;$i $_nmsg .= dechex(mt_rand(0,15));
}

$_img = imagecreatetruecolor($_width,$_height);



说是这里的错误





打了代码就是不显示  我的是火狐浏览器

那你根本就没有加载 php_gd 扩展

Fatal error: Call to undefined function imagecreatetruecolor() in D:\wamp\www\TestGuest0.9\code.php on line 29
  


这个报错
这个错是没找到imagecreatetruecolor()这个方法,你检查一下你的php扩展的php_gd2开启没?

没开  刚在百度查的 我都不知道这个,有学点知识

那你根本就没有加载 php_gd 扩展



Fatal error: Call to undefined function imagecreatetruecolor() in D:\wamp\www\TestGuest0.9\code.php on line 29
  


这个报错
这个错是没找到imagecreatetruecolor()这个方法,你检查一下你的php扩展的php_gd2开启没?

最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
豆包 AI 助手文章总结
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号