PHP Function Zencode
A function is a piece of code that can be used multiple times and accepts inputs (in the form of arguments) and returns a value. PHP has thousands of built-in functions that can be used to perform various tasks. Functions help in reusability of code, separation of logic and making the code easier to understand.
gzencode() compresses the given string using zlib compressed data format. This is similar to gzip compression but differs in that it doesn't include header information.
The gzip format (which gzencode() follows) has a header containing optional metadata, the DEFLATE compressed data and then a footer with length check and CRC32 checksum. The zlib format (which gzcompress() follows) has a shorter header that only serves to identify the compression format, the DEFLATE compressed data and then the Adler-32 checksum.
The last four bytes of output are the Adler-32 checksum and not the CRC32 as gzip expects. This is because gzencode() uses the zlib library and Mark Adler was one of its authors. Hence it follows the specification whereas gzip uses its own implementation which doesn't.