It may be difficult to understand the differences between "gzcompress", "gzdeflate" and "gzencode". Here are my notes:
gzcompress()
------------
Uses ZLIB_ENCODING_DEFLATE (https://www.php.net/manual/en/zlib.constants.php#constant.zlib-encoding-deflate)
ZLIB compression algorithm as per RFC 1950.
Compatible with pigz. (Not compatible with gzip.)
Has a header (compression details, begins with 0x78) and a footer (Adler32 checksum of uncompressed data in big-endian).
gzdeflate()
------------
Uses ZLIB_ENCODING_RAW (https://www.php.net/manual/en/zlib.constants.php#constant.zlib-encoding-raw)
DEFLATE algorithm as per RFC 1951.
No header and footer. Pure DEFLATE.
gzencode()
------------
Uses ZLIB_ENCODING_GZIP (https://www.php.net/manual/en/zlib.constants.php#constant.zlib-encoding-gzip)
GZIP algorithm as per RFC 1952.
Compatible with gzip.
Header begins with magic number 0x1f8b, then compression method 8 (DEFLATE), no file flags, no timestamp, with operating system ID.
Footer contains CRC32 checksum of uncompressed data and then size of uncompressed data, both in little-endian.