Take note that if you change zlib output compression setting in between ob_start and ob_end_clean or ob_end_flush, you will get an error: ob_end_flush() failed to delete buffer zlib output compression
Example:
<?php
ob_start();
$output = ob_get_contents();
ini_set('zlib.output_compression', '1');
ob_end_clean();
?>
ob_end_clean(); in this example will throw the error.