O'Reilly logo

Core PHP Programming, Third Edition by Leon Atkinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8.4. Output Buffering

The output buffering commands add a layer of buffering controlled by PHP in addition to whatever buffering the Web server uses. Some performance penalty may be incurred by adding another layer of buffering, but you may decide the greater control you have is worth the price.

When ob_start is called, all output by functions such as print and echo is held back in a buffer, a large area of memory. The contents of the buffer may be sent to the browser using ob_end_flush, or it may be thrown away using ob_end_clean. As you recall from Chapter 7, headers cannot be sent after the first content is sent. Therefore, these functions allow you to avoid errors created by sending headers after content.

ob_clean()

This function erases the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required