top-think / think-captcha

thinkphp 验证码类库

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

验证码无法显示有bug

yuan1994 opened this issue · comments

commented

我的群里某PHPer遇到验证码无法显示的问题,经过我们一起进行原因排除,发现验证码输出前未清空缓冲池,请官方在合适的地方加上如下代码:

namespace think\captcha;

use think\Config;

class CaptchaController
{
    public function index($id = "")
    {
        $captcha = new Captcha((array)Config::get('captcha'));

       // 就是这一句
        ob_clean();

        return $captcha->entry($id);
    }
}
commented

检查一下是不是有的文件有BOM头。正常情况下不会在Response之前输出任何东西。

ob操作应该成对出现,否则就可能打乱原有嵌套关系。