简体   繁体   English

输出缓冲区内的错误

[英]Errors inside of output buffer

I'm having some problems with the output buffer. 我的输出缓冲区有问题。 I am buffering my script and printing the result using a callback. 我正在缓冲脚本并使用回调打印结果。 The problem is that if a error is thrown at any point, nothing is being shown and I am getting a blank screen. 问题是,如果在任何时候抛出错误,则什么也没有显示,并且我得到了空白屏幕。 I have tried setting my own custom error handlers but nothing seems to work. 我尝试设置自己的自定义错误处理程序,但似乎没有任何效果。 I have a feeling this is because the errors are causing my buffer to call the callback method instead of my error handler. 我感觉这是因为错误导致我的缓冲区调用回调方法而不是我的错误处理程序。 Either that or it's because I have the error handler as a static method, but changing that causes issues elsewhere. 要么是因为我将错误处理程序作为静态方法,但是进行更改会导致其他问题。

I'd really appreciate any help because this one has me stumped! 我真的很感激任何帮助,因为这让我难过!

public function constructor()
{
    ob_start(array(__CLASS__, 'render'));
    self::$buffer_level = ob_get_level();

    set_error_handler(array(__CLASS__, 'exception_handler'));
    set_exception_handler(array(_C_LASS__, 'exception_handler'));

    RUNNING MY SCRIPT HERE

    ob_end_flush();
}

public static function exception_handler($exception, $message = NULL, $file = NULL, $line = NULL)
{
    while (ob_get_level() > self::$buffer_level)
    {
    ob_end_clean();
    }

    echo $exception.' - '.$message.' - '.$file.' - '.$line.'<br/>';
}  
_C_LASS__

看起来您放错了_

Damn, that is actually a typo which isn't in the script, so that isn't what is causing the problem. 该死的,这实际上是打字错误,不在脚本中,所以不是引起问题的原因。 Good spot though! 不错的地方!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM