phpoutput-buffering

Difference between ob_get_clean and ob_get_flush


They both seem to do the same thing: return the output buffer content to you and delete it aftewards.

Which one should I use?


Solution

  • To directly try to answer your question:

    If you wish to begin output buffering again after flushing the buffer, then use ob_get_clean as output buffering will still be ready without having turn it back on. (remember this can only be used if no text, even whitespace is echo'd to the browser). Thus for more general uses, all my programming books err towards ob_get_flush (as only one buffer per most scripts)