13.1 AdvantagesThis is NOT the latest copy of this book; click here for the latest version.
Forget having to send your cookies near the start of your page! Output buffering lets you "send" cookies at any point your script - although, of course, it just stores the cookies separately to the HTML data then sends them together at the end, in the correct order. The bulking together of data also provides quite a performance improvement - PHP literally hangs on to all data until you instruct it to send, at which point all data is sent in one chunk.
Once you are using output buffering, you can compress content before you send it. Due to the fact that HTML is lots of very simple, repeating tags, and normal writing on a site is also very easy to compress, compressing your pages can make a big dent in the amount of bandwidth your site (and your visitor!) uses.
One final advantage is that output buffers are stackable, meaning that you can have several buffers working on top of each other, sending to output whichever ones you want.
|
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.
My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!
|