PHP supports output compression via PHP's ouput buffering features and the zlib extension.

The simplest way is to use the ob_start ('ob_gzhandler') or use the configuration options zlib.output_compression and zlib.compression_level

HTTP_Compress
Alternatively, you can use PEAR's excellent HTTP_Compress class that will handle everything related to HTTP_Compression for you...

<?php
require_once 'HTTP/Compress.php';

HTTP_Compress::start ();
print 
"Some data\n";
print 
"Some more data\n";
print 
"Even _more_ data\n";
HTTP_Compress::output ();
?>