They both seem to do the same thing: return the output buffer content to you and delete it aftewards.
Which one should I use?
They both seem to do the same thing: return the output buffer content to you and delete it aftewards.
Which one should I use?
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)
ob_get_clean
ends output buffering. You'd need to turn it back on again. –
Atombomb ob_get_clean()
removes the buffer (without printing it), and returns its content.
ob_get_flush()
prints the buffer, removes it, and returns its content.
Both function will terminate the buffer.
ob_get_clean
will just return the contents of the buffer and assign it to whatever variable you want it to, but it will not output anything.
ob_get_flush
on the other hand, does everything that ob_get_clean
does, but it also outputs the content.
Both functions clear the output buffer, turn off output buffering, and return the previous buffer value.
However, ob_get_flush
first sends the current buffer to the client, whereas ob_get_clean
just discards it.
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)
ob_get_clean
ends output buffering. You'd need to turn it back on again. –
Atombomb © 2022 - 2024 — McMap. All rights reserved.