<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>ob_start callback function to gzip output buffer</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ob-get-status.html">ob_get_status</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ob-implicit-flush.html">ob_implicit_flush</a></div> <div class="up"><a href="ref.outcontrol.html">Output Control Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.ob-gzhandler" class="refentry"> <div class="refnamediv"> <h1 class="refname">ob_gzhandler</h1> <p class="verinfo">(PHP 4 >= 4.0.4, PHP 5)</p><p class="refpurpose"><span class="refname">ob_gzhandler</span> — <span class="dc-title">ob_start callback function to gzip output buffer</span></p> </div> <div class="refsect1 description" id="refsect1-function.ob-gzhandler-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><strong>ob_gzhandler</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$buffer</code></span> , <span class="methodparam"><span class="type">int</span> <code class="parameter">$mode</code></span> )</div> <p class="para rdfs-comment"> <span class="function"><strong>ob_gzhandler()</strong></span> is intended to be used as a callback function for <span class="function"><a href="function.ob-start.html" class="function">ob_start()</a></span> to help facilitate sending gz-encoded data to web browsers that support compressed web pages. Before <span class="function"><strong>ob_gzhandler()</strong></span> actually sends compressed data, it determines what type of content encoding the browser will accept ("gzip", "deflate" or none at all) and will return its output accordingly. All browsers are supported since it's up to the browser to send the correct header saying that it accepts compressed web pages. If a browser doesn't support compressed pages this function returns <strong><code>FALSE</code></strong>. </p> </div> <div class="refsect1 parameters" id="refsect1-function.ob-gzhandler-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">buffer</code></em></span> <dd> <p class="para"> </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">mode</code></em></span> <dd> <p class="para"> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.ob-gzhandler-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> </p> </div> <div class="refsect1 changelog" id="refsect1-function.ob-gzhandler-changelog"> <h3 class="title">Changelog</h3> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>4.0.5</td> <td> The <em><code class="parameter">mode</code></em> parameter was added. </td> </tr> </tbody> </table> </p> </div> <div class="refsect1 examples" id="refsect1-function.ob-gzhandler-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-471"> <p><strong>Example #1 <span class="function"><strong>ob_gzhandler()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /><br />ob_start</span><span style="color: #007700">(</span><span style="color: #DD0000">"ob_gzhandler"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?><br /></span><html><br /><body><br /><p>This should be a compressed page.</p><br /></body><br /></html></span> </code></div> </div> </div> </p> </div> <div class="refsect1 notes" id="refsect1-function.ob-gzhandler-notes"> <h3 class="title">Notes</h3> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> <span class="function"><strong>ob_gzhandler()</strong></span> requires the <a href="ref.zlib.html" class="link">zlib</a> extension. </p> </p></blockquote> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> You cannot use both <span class="function"><strong>ob_gzhandler()</strong></span> and <a href="zlib.configuration.html#ini.zlib.output-compression" class="link">zlib.output_compression</a>. Also note that using <a href="zlib.configuration.html#ini.zlib.output-compression" class="link"> zlib.output_compression</a> is preferred over <span class="function"><strong>ob_gzhandler()</strong></span>. </p> </p></blockquote> </div> <div class="refsect1 seealso" id="refsect1-function.ob-gzhandler-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.ob-start.html" class="function" rel="rdfs-seeAlso">ob_start()</a> - Turn on output buffering</span></li> <li class="member"> <span class="function"><a href="function.ob-end-flush.html" class="function" rel="rdfs-seeAlso">ob_end_flush()</a> - Flush (send) the output buffer and turn off output buffering</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ob-get-status.html">ob_get_status</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ob-implicit-flush.html">ob_implicit_flush</a></div> <div class="up"><a href="ref.outcontrol.html">Output Control Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>