<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.zlib.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.gzencode.php',
    1 => 'gzencode',
    2 => 'Create a gzip compressed string',
  ),
  'up' => 
  array (
    0 => 'ref.zlib.php',
    1 => 'Zlib-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.gzdeflate.php',
    1 => 'gzdeflate',
  ),
  'next' => 
  array (
    0 => 'function.gzeof.php',
    1 => 'gzeof',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/zlib/functions/gzencode.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.gzencode" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">gzencode</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">gzencode</span> &mdash; <span class="dc-title">Create a gzip compressed string</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.gzencode-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>gzencode</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$data</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$level</code><span class="initializer"> = -1</span></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$encoding</code><span class="initializer"> = <strong><code><a href="zlib.constants.php#constant.zlib-encoding-gzip">ZLIB_ENCODING_GZIP</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">   
   This function returns a compressed version of the input
   <code class="parameter">data</code> compatible with the output of the
   <strong class="command">gzip</strong> program.
  </p>
  <p class="para">
   For more information on the GZIP file format, see the document:
   <a href="https://datatracker.ietf.org/doc/html/rfc1952" class="link external">&raquo;&nbsp;GZIP file format specification
   version 4.3</a> (RFC 1952).
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.gzencode-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">data</code></dt>
     <dd>
      <p class="para">
       The data to encode.
      </p>
     </dd>
    
    
     <dt><code class="parameter">level</code></dt>
     <dd>
      <p class="para">
       The level of compression. Can be given as 0 for no compression up to 9
       for maximum compression. If not given, the default compression level will
       be the default compression level of the zlib library.
      </p>
     </dd>
    
    
     <dt><code class="parameter">encoding</code></dt>
     <dd>
      <p class="para">
       The encoding mode. Can be <strong><code><a href="zlib.constants.php#constant.force-gzip">FORCE_GZIP</a></code></strong> (the default)
       or <strong><code><a href="zlib.constants.php#constant.force-deflate">FORCE_DEFLATE</a></code></strong>. 
      </p>
      <p class="para">
       <strong><code><a href="zlib.constants.php#constant.force-deflate">FORCE_DEFLATE</a></code></strong> generates
       RFC 1950 compliant output, consisting of a zlib header, the deflated
       data, and an Adler checksum.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.gzencode-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   The encoded string, or <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> if an error occurred.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.gzencode-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   The resulting data contains the appropriate headers and data
   structure to make a standard .gz file, e.g.:
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 Creating a gzip file</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$data </span><span style="color: #007700">= </span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">"bigfile.txt"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$gzdata </span><span style="color: #007700">= </span><span style="color: #0000BB">gzencode</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">, </span><span style="color: #0000BB">9</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">file_put_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">"bigfile.txt.gz"</span><span style="color: #007700">, </span><span style="color: #0000BB">$gzdata</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.gzencode-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.gzdecode.php" class="function" rel="rdfs-seeAlso">gzdecode()</a> - Dekodiert eine gzip-komprimierte Zeichenkette</span></li>
    <li><span class="function"><a href="function.gzdeflate.php" class="function" rel="rdfs-seeAlso">gzdeflate()</a> - Komprimiert eine Zeichenkette</span></li>
    <li><span class="function"><a href="function.gzinflate.php" class="function" rel="rdfs-seeAlso">gzinflate()</a> - Dekomprimiert eine komprimierte Zeichenkette</span></li>
    <li><span class="function"><a href="function.gzuncompress.php" class="function" rel="rdfs-seeAlso">gzuncompress()</a> - Dekomprimiert einen komprimierten String</span></li>
    <li><span class="function"><a href="function.gzcompress.php" class="function" rel="rdfs-seeAlso">gzcompress()</a> - Komprimiert einen String</span></li>
    <li>
     <a href="https://datatracker.ietf.org/doc/html/rfc1950" class="link external">&raquo;&nbsp;
      ZLIB Compressed Data Format Specification (RFC 1950)
     </a>
    </li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>