Turn on Output buffering in PHP, this can be done at the php.ini level, or in .htaccess
http://www.php.net/manual/en/outcontrol.configuration.php#ini.output-buffering
Then all your output will be cached in a buffer until your script ends, and it's sent at once. This is often good from a performance perspective (as your server sends fewer, larger, chunks of data). Depending on your site architecture you may want to put a flush(); in after your HTML headers are generated.