php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #15930 gzencode can't have a level
Submitted: 2002-03-07 07:37 UTC Modified: 2002-03-12 08:39 UTC
From: jbgagnon at apic dot fr Assigned: sr (profile)
Status: Closed Package: Documentation problem
PHP Version: 4.1.1 OS: windows 2000
Private report: No CVE-ID: None
 [2002-03-07 07:37 UTC] jbgagnon at apic dot fr
<?php
$data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
$gzdata = gzencode($data);
echo strlen($gzdata),":ok<BR>";
$gzdata = gzencode($data,9);
echo strlen($gzdata),":bad always 10<BR>";
?>

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-03-07 10:50 UTC] sr@php.net
That's an error in the documentation.

The optional second parameter doesn't set the compression level, it does set the compression mode, i.e. you can use FORCE_GZIP or FORCE_DEFLATE in order to use gzip/deflate compression. The compression level is always the default Z_DEFAULT_COMPRESSION.

If nobody objects (does anybody use this parameter?) I'll fix the documentation ...

 [2002-03-07 11:41 UTC] jbgagnon at apic dot fr
YES, I use it. before I use gzopen($fic,"wb9"); with a temporary file the compression was better than gzencode.
For passing information from serveur to client, the size of data is very important. I prefer spending 20 ms for much compression than 30 sec more for download.
but if it is possible to change the Z_DEFAULT_COMPRESSION,
it's ok I always use the same (maxi) compression.
 [2002-03-07 12:42 UTC] sr@php.net
Z_DEFAULT_COMPRESSION is a constant of the zlib include file, so you could change it only with a recompile of php.

As a workaround maybe you can use gzdeflate() or gzcompress(), there the second parameter is the compression level. But then you have to manually add the gzip headers (and maybe the CRC) if you need them.
 [2002-03-07 13:04 UTC] jbgagnon at apic dot fr
Well, I prefer the fonctionnality in documentation
or something like : gzencode($data[,$level[,$mode]])

It would be much easy to use, than make a gzip by hand with header,crc, ...

in "User Contributed Notes" two another persons report this problem. We can perhaps ask them.
 [2002-03-12 08:39 UTC] sr@php.net
Fixed in latest cvs.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Aug 16 08:01:28 2024 UTC