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


Comments

Popular posts from this blog

How to check browser cookie enabled with php and javascript

cookie and subdomains

PHP Best Practise