JosephLenton / PHP-Error

Better error reporting for PHP, and prettier too!
1.35k stars 151 forks source link

White page when application using output buffers triggers notice/warning. #34

Open Paso opened 11 years ago

Paso commented 11 years ago

Cleaning output buffers (preferably in a loop as buffers can be nested) in ErrorHandler->discardBuffer() solves the problem.

The following code recreates the problem:

<?php

ini_set("display_errors", 1);
ini_set("display_startup_errors", 1);
error_reporting(-1);
require_once('../library/php_error.php');
\php_error\reportErrors();

ob_start();

echo "before";
trigger_error("ERROR", E_USER_NOTICE);
echo "after";

ob_flush();
allixsenos commented 11 years ago

adding

while(ob_end_clean());

at the beginning of discardBuffer() fixes it...

websiteduck commented 9 years ago

This will avoid an error if you're not currently in a buffer:

while (ob_get_level() > 0) ob_end_clean();

kenorb commented 8 years ago

Fixed in PR: #94