Notice: ob_end_clean(): failed to delete buffer.



Hello Coders,

So as the title reads; I am going to talk of below error that gave me a nightmare recently.

Notice: ob_end_clean(): failed to delete buffer

I use Spout Excel plugin (get it here) to write excel reports for my project.
One fine day the excel stopped working giving following error for each and every report 😢


I searched and searched and searched to understand the reason for this error. I thought I wrote something that was writing some corrupt data in the file.

However, then I found out that removing new lines after the closing PHP tag in one of my file fixed the issue. I am referring to the PHP closing tag i.e. ?>

It so appears that new line after the closing tag writes something in the output buffer even before my excel content was being written.

Such a silly issue caused catastrophic impact to the production system for one good day.

But all's well that ends well ..
- Happy coding -