PHP Function - OB_Get_Level()
ob_get_level() is one of the most important php function for web developers. It lets you know how many levels of output buffering are active in your script. This article will help you understand the basics of buffering and how it works in php.
Basically, a buffer is used to store data temporarily before sending it to another location. For example, if you were speaking into your microphone, what you would hear is the sound that was stored in the buffer before it was sent to the speaker. Similarly, when you echo something in a php script, what is printed on the screen is actually what has been sent to the browser's buffer. Buffering allows for more control over when a script's content is actually sent to the browser.
There are several php functions that you can use to handle output buffering, but there are a few that are more useful than others. These include ob_get_contents, ob_get_length and ob_get_status.
ob_get_level() returns the level of nested output buffering handlers or zero if output buffering is not active. ob_get_contents() returns the contents of an output buffer. ob_get_length() returns the length of the buffered data. ob_get_status() returns an array of status information either for the top level buffer or for all output buffer levels if full_status is set to TRUE. ob_end_flush() flushes (sends) the buffered data to the browser. ob_end_clean() empties the buffer and closes it. This function is similar to ob_end_flush but it does not destroy the buffer.