I have read quite a bit of material on Internet, where different authors suggest using output buffering. The funny thing is that most authors argument for its use because it allows to set HTTP response headers while also generating response output. Frankly, if for no other reason, I think that responsible web applications SHOULD NOT mix outputting headers and content, and web developers instead should look for the errors where headers are in fact attempted to be sent after output has been generated - it most likely indicates errors in script flow control logic. This is my first argument against PHP's ob_ output buffering API. Even if for that little convenience it gives - "mixing" headers with output - that is not a good enough reason to use it, unless one needs to hack up scripts fast, which is not my current task at all.
Are there other, more important advantages to output buffering?
Also, I think most people meeting or dealing with the output buffering API do not think about the fact that even without the explicit output buffering enabled, PHP in combination with the web-server it is plugged into, STILL does some internal buffering. It is easy to check - do an echo of some short string, sleep for say 10 seconds, and do another echo. Request your script with a browser and watch as the blank page pauses for 10 seconds, and then both lines are shown at the same time. Before some say that it is a rendering artefact, not traffic, tracing the actual traffic between the client and the server shows that the server has generated the 'Content-Length' header with an appropriate value for the entire output - suggesting that the output was not sent progressively with each 'echo' call, but accumulated in some buffer and then sent on script termination. This is one of my gripes with explicit output buffering - why do we need two different output buffer implementations on top of one another? May it be because the internal (inaccessible) PHP/Web-server output buffering is subject to conditions a PHP developer cannot control, and is thus not really usable?
In any case, I for one, start to think one should avoid explicit output buffering (the series of ob_ functions) and rely on the implicit one, assisting it with the good flush function, when necessary. Maybe if there was some guarantee that a web server one uses actually sends output to the client on each echo/print call, then it would be useful to set up explicit buffering - after all one does not want to send response to the client with some 100 byte chunks. But the alternative with two buffers seems like a somewhat useless layer of abstraction.
Opinions are very welcome...