Output buffering in php

Output buffering is used by PHP to improve performance and to perform a few tricks.

Without output buffering (the default), your HTML is sent to the browser in pieces as PHP processes through your script. With output buffering, your HTML is stored in a variable and sent to the browser as one piece at the end of your script.

Advantages of output buffering:

  • Turning on output buffering alone decreases the amount of time it takes to download and render our HTML because it’s not being sent to the browser in pieces as PHP processes the HTML.

  • All the fancy stuff we can do with PHP strings, we can now do with our whole HTML page as one variable.

  • If you’ve ever encountered the message “Warning: Cannot modify header information – headers already sent by (output)” while setting cookies, you’ll be happy to know that output buffering is your answer.

Use Facebook to Comment on this Post


Popular posts from this blog

Get URL Parameters Using Javascript

PHP 5.4 beta1 released

Ternary Operators