当前位置: 移动技术网 > IT编程>开发语言>PHP > ThinkPHP3.2.1图片验证码实现方法

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

2017年12月12日  | 移动技术网IT编程  | 我要评论

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

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

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

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

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

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

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

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

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

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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网