今天用到图片验证码的功能,在网上找到ThinkPHP的以下代码:
Public function verify(){
import('think.Image');
Image::buildImageVerify();
}添加到Controller中,通过地址“http://localhost/index.php/passport/index/verify”来访问,却提示以下错误:
Class 'Passport\Controller\Image' not found
Public function verify(){
$Verify = new \Think\Verify();
$Verify->entry();
}但刷新浏览之后又出错了“Call to undefined function Think\imagecreate()”
搜索之后发现是没有启用“extension=php_gd2.dll”扩展,在php.ini中去掉前边的分号; 再刷新浏览图片验证码就出来了。
本文介绍了如何在ThinkPHP 3.2.1中正确实现图片验证码功能,包括使用正确的验证码生成代码、解决类未找到的问题及GD库扩展配置等。
571

被折叠的 条评论
为什么被折叠?



