php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #7033 gzcompress does not work as expected
Submitted: 2000-10-05 04:24 UTC Modified: 2001-01-22 21:32 UTC
From: mg at plum dot de Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.0.2 OS: Linux, rh6.2 2.4.0-test6
Private report: No CVE-ID: None
 [2000-10-05 04:24 UTC] mg at plum dot de
$gzip = gzcompress($h->inhalt);
header("Content-Encoding: gzip");
print($gzip);
$fp = fopen("/tmp/file.gz","w");
fputs($fp,$gzip);
fclose($fp);

does not work, the browser does not display anything, 
and gzip -d /tmp/file.gz tells me that the file is not
a valid gzip file.

If I do:
     $fp = gzopen ("/tmp/file.gz", "w");
     gzputs($fp,$h->inhalt);
     gzclose($fp);
and then gzip -d again, everything works.

The file generated by gzcompress is about 20 Bytes shorter
than the one from gzopen, so I suspect there is probably 
some problem with NULL-Termination...

TIA,
   Michael

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-10-11 09:35 UTC] stas@php.net
Yes, gzcompress and gzopen&friends are different function. The latter does not put gzip headers (whatever they are) to the output. You should use gzopen, etc. if you want to be gzip-compatible. That's how it is in zlib library. 

Since this about the third time people ask this, I move this to doc's problem. 
 [2000-10-11 09:37 UTC] stas@php.net
See also #6481
 [2001-01-22 21:32 UTC] jimw@php.net
doesn't do gzip compression (does deflate), updated docs.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 08:01:28 2024 UTC