Tuesday, 22 November 2016

buffer - Why buffering is not enabled by default in php

Answer


I wonder about buffering in php. I have read a lot of threads about this.



How to fix “Headers already sent” error in PHP



Why use output buffering in PHP?



I have read only about advantages, there was not informations about disadvantages of using buffering.



Ex.





Advantages of output buffering for Web developers




  • 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.





If output buffering provide only advantages, why I should turn it on manually by function ob_start() or in any other way?

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...