槐佑是神 2021-12-07 19:39 采纳率: 33.3%
浏览 43
已结题

tp6框架验证码加载失败

已经通过composer安装了,tp6的验证码扩展,使用的是phpstudy集成环境

并且开启了gd库,引擎模板也可以使用,但就是在浏览器输出图片裂开。


单独打开http://localhost/captcha.html 界面出现致命错误:

#0 [0]Error in Captcha.php line 181
Call to undefined function think\captcha\imagecreate()
        $this->configure($config);

        $generator = $this->generate();

        // 图片宽(px)
        $this->imageW || $this->imageW = $this->length * $this->fontSize * 1.5 + $this->length * $this->fontSize / 2;
        // 图片高(px)
        $this->imageH || $this->imageH = $this->fontSize * 2.5;
        // 建立一幅 $this->imageW x $this->imageH 的图像
        $this->im = imagecreate($this->imageW, $this->imageH);
        // 设置背景
        imagecolorallocate($this->im, $this->bg[0], $this->bg[1], $this->bg[2]);

        // 验证码字体随机颜色
        $this->color = imagecolorallocate($this->im, mt_rand(1, 150), mt_rand(1, 150), mt_rand(1, 150));

        // 验证码使用随机字体
        $ttfPath = __DIR__ . '/../assets/' . ($this->useZh ? 'zhttfs' : 'ttfs') . '/';

度娘了一番后无果,根据慕课教程实战开发进行学习时,发现讲师并未进行其他设置


是我什么地方遗漏了吗?

  • 写回答

1条回答 默认 最新

  • 「已注销」 2021-12-07 21:38
    关注

    在HTML页面加入

    {:captcha_img()}

    或者

    captcha
    、 了吗
    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 9月22日
  • 创建了问题 12月7日

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题