Output buffering with ob_start() and ob_end_flush().
Output buffering (PHP 4.0) was originally designed to solve HTTP header errors.
<?php ob_start();
// entire script, code, or page here
ob_end_flush(); ?>
Although ob_end_flush() isn't needed in MOST cases because it is called automatically at the end of script execution by PHP itself when output buffering is turned on either in the php.ini or by calling ob_start(). I should also mention that Output buffers are stackable, that is, you may call ob_start() while another ob_start() is active. Just make sure that you call ob_end_flush() the appropriate number of times. If multiple output callback functions are active, output is being filtered sequentially through each of them in nesting order.