13 Output BufferingThis is NOT the latest copy of this book; click here for the latest version.
Output Buffering was introduced in PHP 4, so is not new in PHP by a long shot, and yet it still has yet to catch on amongst the masses despite the added flexibility it brings.
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 contents13.1. Advantages
13.2. Performance Considerations
13.3. Getting started: ob_start(), ob_end_flush(), and ob_end_clean()
13.4. Reusing buffers: ob_flush() and ob_clean()
13.5. Stacking buffers
13.6. Flushing stacked buffers
13.7. Reading buffers: ob_get_contents()
13.8. Other OB functions: ob_get_length(), ob_get_level(), and ob_list_handlers()
13.9. Flushing output: flush()
13.10. Compressing output
13.11. URL rewriting: output_add_rewrite_var() and output_reset_rewrite_vars()
13.12. Summary
13.13. Exercises
13.14. Further reading
13.15. Next chapter
|
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!
|