<!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>Binary-safe gz-file write</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.gzuncompress.html">gzuncompress</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.readgzfile.html">readgzfile</a></div> <div class="up"><a href="ref.zlib.html">Zlib Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.gzwrite" class="refentry"> <div class="refnamediv"> <h1 class="refname">gzwrite</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">gzwrite</span> — <span class="dc-title">Binary-safe gz-file write</span></p> </div> <div class="refsect1 description" id="refsect1-function.gzwrite-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><strong>gzwrite</strong></span> ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$zp</code></span> , <span class="methodparam"><span class="type">string</span> <code class="parameter">$string</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$length</code></span> ] )</div> <p class="para rdfs-comment"> <span class="function"><strong>gzwrite()</strong></span> writes the contents of <em><code class="parameter">string</code></em> to the given gz-file. </p> </div> <div class="refsect1 parameters" id="refsect1-function.gzwrite-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">zp</code></em></span> <dd> <p class="para"> The gz-file pointer. It must be valid, and must point to a file successfully opened by <span class="function"><a href="function.gzopen.html" class="function">gzopen()</a></span>. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">string</code></em></span> <dd> <p class="para"> The string to write. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">length</code></em></span> <dd> <p class="para"> The number of uncompressed bytes to write. If supplied, writing will stop after <em><code class="parameter">length</code></em> (uncompressed) bytes have been written or the end of <em><code class="parameter">string</code></em> is reached, whichever comes first. </p> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> Note that if the <em><code class="parameter">length</code></em> argument is given, then the <a href="info.configuration.html#ini.magic-quotes-runtime" class="link">magic_quotes_runtime</a> configuration option will be ignored and no slashes will be stripped from <em><code class="parameter">string</code></em>. </p> </p></blockquote> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.gzwrite-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the number of (uncompressed) bytes written to the given gz-file stream. </p> </div> <div class="refsect1 examples" id="refsect1-function.gzwrite-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-826"> <p><strong>Example #1 <span class="function"><strong>gzwrite()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$string </span><span style="color: #007700">= </span><span style="color: #DD0000">'Some information to compress'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$gz </span><span style="color: #007700">= </span><span style="color: #0000BB">gzopen</span><span style="color: #007700">(</span><span style="color: #DD0000">'somefile.gz'</span><span style="color: #007700">,</span><span style="color: #DD0000">'w9'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">gzwrite</span><span style="color: #007700">(</span><span style="color: #0000BB">$gz</span><span style="color: #007700">, </span><span style="color: #0000BB">$string</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">gzclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$gz</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.gzwrite-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.gzread.html" class="function" rel="rdfs-seeAlso">gzread()</a> - Binary-safe gz-file read</span></li> <li class="member"> <span class="function"><a href="function.gzopen.html" class="function" rel="rdfs-seeAlso">gzopen()</a> - Open gz-file</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.gzuncompress.html">gzuncompress</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.readgzfile.html">readgzfile</a></div> <div class="up"><a href="ref.zlib.html">Zlib Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>