If php is installed as an apache module, in your htaccess file, which you can put in only certain directories if you want to compress some pages, or you can put it in the root directory to do it for all php pages above that root, you can put this:
php_value zlib.output_compression On
php_value zlib.output_compression_level [1-9]
or if php isnt an apache module that wont work in your htaccess file so you can put this at the top of all php scripts.
ini_set("zlib.output_compression", "On");
ini_set("zlib.output_compression_level", 1-9);
obviously php will only compress the pages when the client browser sends a header Accept-Encoding: gzip or deflate
see www.php.net/zlib for more details.