title: How does gzcompress work?
body: <p>I'm wondering about why I need to cut off the last 4 Characters, after using gzcompress().</p>
  
  <p>Here is my code:</p>
  
  <pre><code>header("Content-Encoding: gzip");
  echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
  $index = $smarty-&gt;fetch("design/templates/main.htm") ."\n&lt;!-- Compressed by gzip --&gt;";
  $this-&gt;content_size = strlen($index);
  $this-&gt;content_crc = crc32($index);
  $index = gzcompress($index, 9);
  $index = substr($index, 0, strlen($index) - 4); // Why cut off ??
  echo $index;
  echo pack('V', $this-&gt;content_crc) . pack('V', $this-&gt;content_size);
  </code></pre>
  
  <p>When I don't cut of the last 4 chars, the source ends like:</p>
  
  <pre><code>[...]
  &lt;!-- Compressed by gzip --&gt;N
  </code></pre>
  
  <p>When I cut them off it reads:</p>
  
  <pre><code>[...]
  &lt;!-- Compressed by gzip --&gt;
  </code></pre>
  
  <p>I could see the additional N only in Chromes Code inspector (not in Firefox and not in IEs source). But there seams to be four additional characters at the end of the code.</p>
  
  <p>Can anyone explain me, why I need to cut off 4 chars?</p>