Okay, here are two ways you can do it:
If you have zlib capabilities in your PHP, then use the gzxxxx commands. Here is modified version of the code on the manual page:
// create temporary file to store compressed data
$filename = tempnam ('/tmp', 'zlibtest').'.gz';
// open the file you want to compress
$fd = fopen("mypage.html", "r");
$contents = fread($fd, filesize("mypage.html"));
fclose($fd);
// open file for writing with maximum compression
$zp = gzopen($filename, "w9");
// write contents to file
gzwrite($zp, $contents);
// close file
gzclose($zp);
// now we will push it back to the browser so the user can download it
// set up the headers so that the browser will recognize the data as a downloadable gzip file
header("Content-type: application/x-gzip");
header("Content-Disposition: attachment; filename=myfile.gz");
// open and print out contents of file
$fd = fopen($filename);
$contents = fread($fd, filesize($filename));
print $contents;
fclose($fd);
hope this helps!
-sridhar