doc-en icon indicating copy to clipboard operation
doc-en copied to clipboard

gzuncompress() unable to handle data from gzcompress($s,1,ZLIB_ENCODING_RAW);

Open divinity76 opened this issue 3 years ago • 1 comments

Description

The following code:

<?php
$data="test";
var_dump(gzuncompress(gzcompress($data,1, ZLIB_ENCODING_DEFLATE)));
var_dump(gzuncompress(gzcompress($data,1,ZLIB_ENCODING_RAW)));

Resulted in this output:

string(4) "test"

Warning: gzuncompress(): data error in /in/Ms5o8 on line 4
bool(false)

But I expected this output instead:

string(4) "test"
string(4) "test"

PHP Version

8.1.11

Operating System

No response

divinity76 avatar Oct 19 '22 09:10 divinity76

This is to be expected; gzuncompress() is for deflated input, while gzinflate() is for raw encoded input: https://3v4l.org/iukbV. This is not sufficiently documented, though.

cmb69 avatar Oct 19 '22 10:10 cmb69