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();
What about using it this way?
if (ob_get_level() == 0) ob_start();