I use output buffering for gzip compression and access to what was put out before in a PHP script:
if(!ob_start(\"ob_gzhandler\")) ob_start();
if (ob_get_level()) echo "ob already started";