Output Buffering

Without output buffering, PHP sends data to your web server as soon as it is ready - this might be line by line or code block by code block. Not only is this slow because of the need to send lots of little bits of data, but it also means you are restricted in the order you can send data. Output buffering cures these ills by enabling you to store up your output and send to send it when you are ready to - or to not send it at all, if you so decide.

Topics covered in this chapter are:

  • When to use output buffering

  • Manipulating multiple buffers

  • Incremental data flushing

  • Output compression

Chapter contents

  1. 13.1. Advantages
  2. 13.2. Performance Considerations
  3. 13.3. Getting started
  4. 13.4. Reusing buffers
  5. 13.5. Stacking buffers
  6. 13.6. Flushing stacked buffers
  7. 13.7. Reading buffers
  8. 13.8. Other OB functions
  9. 13.9. Flushing output
  10. 13.10. Compressing output
  11. 13.11. URL rewriting
  12. 13.12. Summary
  13. 13.13. Exercises
  14. 13.14. Further reading
  15. 13.15. Next chapter

Want to learn PHP 7?

Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!

If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: Advantages >>

Previous chapter: Next chapter

Jump to:


Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.