<?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 => 'ru',
  ),
  'this' => 
  array (
    0 => 'function.gzcompress.php',
    1 => 'gzcompress',
    2 => 'Сжать строку',
  ),
  'up' => 
  array (
    0 => 'ref.zlib.php',
    1 => 'Функции Zlib',
  ),
  'prev' => 
  array (
    0 => 'function.gzclose.php',
    1 => 'gzclose',
  ),
  'next' => 
  array (
    0 => 'function.gzdecode.php',
    1 => 'gzdecode',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ru',
    'path' => 'reference/zlib/functions/gzcompress.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.gzcompress" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">gzcompress</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.1, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">gzcompress</span> &mdash; <span class="dc-title">Сжать строку</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.gzcompress-description">
  <h3 class="title">Описание</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>gzcompress</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-deflate">ZLIB_ENCODING_DEFLATE</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">
   Данная функция сжимает строку используя формат данных <code class="literal">ZLIB</code>.
  </p>
  <p class="para">
   Подробнее про алгоритм сжатия ZLIB смотрите документ
   &quot;<a href="https://datatracker.ietf.org/doc/html/rfc1950" class="link external">&raquo;&nbsp;Формат сжатия ZLIB. Спецификация версии 3.3</a>&quot; (RFC 1950).
  </p>
  <blockquote class="note"><p><strong class="note">Замечание</strong>: 
   <p class="para">
    Это <em>не</em> то же самое, что и gzip-сжатие, которое включает в себя некоторые данные
    заголовка. Информацию о gzip-сжатии смотрите <span class="function"><a href="function.gzencode.php" class="function">gzencode()</a></span>.
   </p>
  </p></blockquote>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.gzcompress-parameters">
  <h3 class="title">Список параметров</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">data</code></dt>
     <dd>
      <p class="para">
       Данные для сжатия.
      </p>
     </dd>
    
    
     <dt><code class="parameter">level</code></dt>
     <dd>
      <p class="para">
       Уровень сжатия. Целое число от 0 до 9 (0 - без сжатия, 9 - максимальное сжатие).
      </p>
      <p class="para">
       Если используется значение -1, то будет установлен принятый в библиотеке zlib по умолчанию уровень сжатия, который равен 6.
      </p>
     </dd>
    
   
     <dt><code class="parameter">encoding</code></dt>
     <dd>
      <p class="para">
       Одна из констант <strong><code><a href="zlib.constants.php#constant.zlib-encoding-raw">ZLIB_ENCODING_<span class="replaceable">*</span></a></code></strong>.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.gzcompress-returnvalues">
  <h3 class="title">Возвращаемые значения</h3>
  <p class="para">
   Сжатая строка или <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> в случае возникновения ошибки.
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.gzcompress-examples">
  <h3 class="title">Примеры</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Пример #1 Пример использования <span class="function"><strong>gzcompress()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$compressed </span><span style="color: #007700">= </span><span style="color: #0000BB">gzcompress</span><span style="color: #007700">(</span><span style="color: #DD0000">'Сожми меня'</span><span style="color: #007700">, </span><span style="color: #0000BB">9</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$compressed</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.gzcompress-seealso">
  <h3 class="title">Смотрите также</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.gzdeflate.php" class="function" rel="rdfs-seeAlso">gzdeflate()</a> - Сжимает строку</span></li>
    <li><span class="function"><a href="function.gzinflate.php" class="function" rel="rdfs-seeAlso">gzinflate()</a> - Распаковать сжатую строку</span></li>
    <li><span class="function"><a href="function.gzuncompress.php" class="function" rel="rdfs-seeAlso">gzuncompress()</a> - Распаковать сжатую строку</span></li>
    <li><span class="function"><a href="function.gzencode.php" class="function" rel="rdfs-seeAlso">gzencode()</a> - Создать сжатую строку gzip</span></li>
   </ul>
  </p>
 </div>

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