Difference between ob_get_clean and ob_get_flush Difference between ob_get_clean and ob_get_flush php php

Difference between ob_get_clean and ob_get_flush


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.