downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/function.gzcompress.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = 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 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.gzcompress.php',
   
1 => 'gzcompress',
  ),
 
'up' =>
  array (
   
0 => 'ref.zlib.php',
   
1 => 'Zlib Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.gzclose.php',
   
1 => 'gzclose',
  ),
 
'next' =>
  array (
   
0 => 'function.gzdecode.php',
   
1 => 'gzdecode',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<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)</p><p class="refpurpose"><span class="refname">gzcompress</span> &mdash; <span class="dc-title">Compress a string</span></p>

 </div>
 <a name="function.gzcompress.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><b>gzcompress</b></span>
    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$data</tt></span>
   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$level</tt><span class="initializer"> = -1</span></span>
  ] )</div>

  <p class="para rdfs-comment">
   This function compress the given string using the <i>ZLIB</i>
   data format.
  </p>
  <p class="para">
   For details on the ZLIB compression algorithm see the document
   &quot;<a href="http://www.faqs.org/rfcs/rfc1950" class="link external">&raquo; ZLIB Compressed Data Format
   Specification version 3.3</a>&quot; (RFC 1950).
  </p>
  <blockquote><p><b class="note">Note</b>:
  
    This is <em class="emphasis">not</em> the same as gzip compression,
    which includes some header data. See <a href="function.gzencode.php" class="function">gzencode()</a>
    for gzip compression.
   <br />
  </p></blockquote>
 </div>

 <a name="function.gzcompress.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">data</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       The data to compress.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">level</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       The level of compression. Can be given as 0 for no compression up to 9
       for maximum compression.
      </p>
     </dd>

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

 <a name="function.gzcompress.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   The compressed string or <b><tt class="constant">FALSE</tt></b> if an error occurred.
  </p>
 </div>

 <a name="function.gzcompress.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 <b>gzcompress()</b> example</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$compressed&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">gzcompress</span><span style="color: #007700">(</span><span style="color: #DD0000">'Compress&nbsp;me'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">9</span><span style="color: #007700">);<br />echo&nbsp;</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>
  </p>
 </div>

 <a name="function.gzcompress.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.gzdeflate.php" class="function" rel="rdfs-seeAlso">gzdeflate()</a> - Deflate a string</li>
    <li class="member"><a href="function.gzinflate.php" class="function" rel="rdfs-seeAlso">gzinflate()</a> - Inflate a deflated string</li>
    <li class="member"><a href="function.gzuncompress.php" class="function" rel="rdfs-seeAlso">gzuncompress()</a> - Uncompress a compressed string</li>
    <li class="member"><a href="function.gzencode.php" class="function" rel="rdfs-seeAlso">gzencode()</a> - Create a gzip compressed string</li>
   </ul><p>
  </p>
 </div>

</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites