Difference between ob_get_clean and ob_get_flush

爱⌒轻易说出口 提交于 2019-12-02 18:48:27

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() removes the buffer (without printing it), and returns its content.

ob_get_flush() prints the buffer, removes it, and returns its content.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!