当前位置:首页 > PHP教程 > PHP常见问题

ThinkPHP3.2.1图片验证码实现方法

本文实例讲述了thinkphp3.2.1图片验证码实现方法。分享给大家供大家参考,具体如下:

今天用到图片验证码的功能,在网上找到thinkphp的以下代码:

public function verify(){ import('think.image'); image::buildimageverify(); }

添加到controller中,通过地址“http://localhost/index.php/passport/index/verify”来访问,却提示以下错误:
class 'passportcontrollerimage' not found

我的thinkphp版本是:3.2.1,经过查看对应版本的文档“http://document.thinkphp.cn/manual_3_2.html#verify”,发现需要使用以下代码:

public function verify(){ $verify = new thinkverify(); $verify->entry(); }

但刷新浏览之后又出错了“call to undefined function thinkimagecreate()”

搜索之后发现是没有启用“extension=php_gd2.dll”扩展,在php.ini中去掉前边的分号; 再刷新浏览图片验证码就出来了。

更多关于thinkphp相关内容感兴趣的读者可查看本站专题:《thinkphp入门教程》、《thinkphp模板操作技巧总结》、《thinkphp常用方法总结》、《smarty模板入门基础教程》及《php模板技术总结》。

希望本文所述对大家基于thinkphp框架的php程序设计有所帮助。



【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!