<!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 read</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.gzputs.html">gzputs</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.gzrewind.html">gzrewind</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.gzread" class="refentry"> <div class="refnamediv"> <h1 class="refname">gzread</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">gzread</span> — <span class="dc-title">Binary-safe gz-file read</span></p> </div> <div class="refsect1 description" id="refsect1-function.gzread-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><strong>gzread</strong></span> ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$zp</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>gzread()</strong></span> reads up to <em><code class="parameter">length</code></em> bytes from the given gz-file pointer. Reading stops when <em><code class="parameter">length</code></em> (uncompressed) bytes have been read or <acronym title="End Of File">EOF</acronym> is reached, whichever comes first. </p> </div> <div class="refsect1 parameters" id="refsect1-function.gzread-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">length</code></em></span> <dd> <p class="para"> The number of bytes to read. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.gzread-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> The data that have been read. </p> </div> <div class="refsect1 examples" id="refsect1-function.gzread-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-823"> <p><strong>Example #1 <span class="function"><strong>gzread()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// get contents of a gz-file into a string<br /></span><span style="color: #0000BB">$filename </span><span style="color: #007700">= </span><span style="color: #DD0000">"/usr/local/something.txt.gz"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$zd </span><span style="color: #007700">= </span><span style="color: #0000BB">gzopen</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">, </span><span style="color: #DD0000">"r"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$contents </span><span style="color: #007700">= </span><span style="color: #0000BB">gzread</span><span style="color: #007700">(</span><span style="color: #0000BB">$zd</span><span style="color: #007700">, </span><span style="color: #0000BB">10000</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">gzclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$zd</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.gzread-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.gzwrite.html" class="function" rel="rdfs-seeAlso">gzwrite()</a> - Binary-safe gz-file write</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> <li class="member"> <span class="function"><a href="function.gzgets.html" class="function" rel="rdfs-seeAlso">gzgets()</a> - Get line from file pointer</span></li> <li class="member"> <span class="function"><a href="function.gzgetss.html" class="function" rel="rdfs-seeAlso">gzgetss()</a> - Get line from gz-file pointer and strip HTML tags</span></li> <li class="member"> <span class="function"><a href="function.gzfile.html" class="function" rel="rdfs-seeAlso">gzfile()</a> - Read entire gz-file into an array</span></li> <li class="member"> <span class="function"><a href="function.gzpassthru.html" class="function" rel="rdfs-seeAlso">gzpassthru()</a> - Output all remaining data on a gz-file pointer</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.gzputs.html">gzputs</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.gzrewind.html">gzrewind</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>