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.
Next chapter: Performance Considerations >>
Previous chapter: Output Buffering
Home: Table of Contents
Copyright ©2015 Paul Hudson. Follow me: @twostraws.