/** * Closes all open output buffers, either by flushing or cleaning all * open buffers, and optionally, the Eight output buffer. * * @param boolean disable to clear buffers, rather than flushing * @param boolean close the eight output buffer * @return void */ public static function close_buffers($flush = YES, $eight_buffer = YES) { if (ob_get_level() >= self::$buffer_level) { // Set the close function $close = $flush === YES ? 'ob_end_flush' : 'ob_end_clean'; while (ob_get_level() > self::$buffer_level) { // Flush or clean the buffer $close(); } if ($eight_buffer === YES) { // This will flush the Eight buffer, which sets self::$output ob_end_clean(); // Reset the buffer level self::$buffer_level = ob_get_level(); } } }