PHP: Hypertext Preprocessor (original) (raw)

zlib_encode

(PHP 5 >= 5.4.0, PHP 7, PHP 8)

zlib_encode — Compress data with the specified encoding

Description

Warning

This function is currently not documented; only its argument list is available.

Return Values

Examples

Example #1 zlib_encode() example

<?php $str = 'hello world'; <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>e</mi><mi>n</mi><mi>c</mi><mo>=</mo><mi>z</mi><mi>l</mi><mi>i</mi><msub><mi>b</mi><mi>e</mi></msub><mi>n</mi><mi>c</mi><mi>o</mi><mi>d</mi><mi>e</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">enc = zlib_encode(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.4306em;"></span><span class="mord mathnormal">e</span><span class="mord mathnormal">n</span><span class="mord mathnormal">c</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal" style="margin-right:0.04398em;">z</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">i</span><span class="mord"><span class="mord mathnormal">b</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.1514em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">e</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mord mathnormal">n</span><span class="mord mathnormal">co</span><span class="mord mathnormal">d</span><span class="mord mathnormal">e</span><span class="mopen">(</span></span></span></span>str, ZLIB_ENCODING_DEFLATE); echo bin2hex($enc); ?>

The above example will output:

789ccb48cdc9c95728cf2fca4901001a0b045d

See Also

Found A Problem?

geniuszxy at outlook dot com

2 years ago

`zlib_encode, gzcompress, gzdeflate and gzencode are the same functions besides the parameter order.

zlib_encode + ZLIB_ENCODING_RAW = gzdeflate
zlib_encode + ZLIB_ENCODING_DEFLATE = gzcompress
zlib_encode + ZLIB_ENCODING_GZIP = gzencode

`