我的输出缓冲区有一些问题。我正在缓冲我的脚本并使用回调打印结果。问题是,如果在任何时候抛出错误,什么都不会显示,我会得到一个空白屏幕。我尝试设置自己的自定义错误处理程序,但似乎没有任何效果。我有一种感觉,这是因为错误导致我的缓冲区调用回调方法而不是我的错误处理程序。要么是这样,要么是因为我将错误处理程序作为静态方法,但改变它会导致其他地方出现问题。
我真的很感激任何帮助,因为这个让我很难过!
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(_CLASS__, '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/>';
}