我正在尝试编写validation码,并在线阅读了一些教程。 所以,我有复制/粘贴这个function:
create_image(); exit(); function create_image() { //Let's generate a totally random string using md5 $md5_hash = md5(rand(0,999)); //We don't need a 32 character long string so we trim it down to 5 $security_code = substr($md5_hash,15,5); //Set the session to store the security code $_SESSION["security_code"] = $security_code; //Set the image width and height $width = 100; $height = 20; //Create the image resource $image = ImageCreate($width,$height); //We are making three colors,white,black and gray $white = ImageColorAllocate($image,255,255); $black = ImageColorAllocate($image,0); $grey = ImageColorAllocate($image,204,204); //Make the background black ImageFill($image,$black); //Add randomly generated string in white to the image ImageString($image,3,30,$security_code,$white); //Throw in some lines to make it a little bit harder for any bots to break ImageRectangle($image,$width-1,$height-1,$grey); imageline($image,$height/2,$width,$width/2,$height,$grey); //Tell the browser what kind of file is come in header("Content-Type: image/jpeg"); //Output the newly created image in jpeg format ImageJpeg($image); //Free up resources ImageDestroy($image); }
致命错误:调用未定义的函数ImageCreate()在C: Program Files Apache Software Foundation Apache2.2 htdocs gtw registration createCaptcha.PHP on line 19
有什么问题? 一些PHP库?
防止盗链图像文件
如何使用硬件video缩放器?
图像差异查看器SVN
如何抓取图像并将其保存在文件夹中
移动/调整窗口大小时闪烁
使用GDI显示图像的红色通道
Qt不在Linux上显示PNG图像
PHP_gd2扩展未启用。
它包含在Windows PHP发行版中,但是您必须在PHP.ini启用它。 要做到这一点,只需打开PHP.ini并取消注释(删除前导; )下面一行:
extension=PHP_gd2.dll
保存,重新启动Apache,你应该没问题。
为了能够使用ImageCreate,您需要将GD库作为PHP安装的一部分。
用PHPinfo()函数检查它是否被安装。 如果没有,你需要添加这个。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。