Bypassing Output Buffering in PHP

I’ve been developing with PHP for over a decade and I just love it when I learn a new trick.

Perhaps you are working on a command line script and want some feedback, but you’re output buffering to generate a fancy report (or something).  You can bypass the output buffering with this little trick



echo "BOOM!\n";

fwrite( STDOUT, "You smell funky\n" );

echo ob_get_clean();


You smell funky