<!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>Seek on a gz-file pointer</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.gzrewind.html">gzrewind</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.gztell.html">gztell</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.gzseek" class="refentry"> <div class="refnamediv"> <h1 class="refname">gzseek</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">gzseek</span> — <span class="dc-title">Seek on a gz-file pointer</span></p> </div> <div class="refsect1 description" id="refsect1-function.gzseek-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><strong>gzseek</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">$offset</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$whence</code><span class="initializer"> = SEEK_SET</span></span> ] )</div> <p class="para rdfs-comment"> Sets the file position indicator for the given file pointer to the given offset byte into the file stream. Equivalent to calling (in C) <em>gzseek(zp, offset, SEEK_SET)</em>. </p> <p class="para"> If the file is opened for reading, this function is emulated but can be extremely slow. If the file is opened for writing, only forward seeks are supported; <span class="function"><strong>gzseek()</strong></span> then compresses a sequence of zeroes up to the new starting position. </p> </div> <div class="refsect1 parameters" id="refsect1-function.gzseek-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">offset</code></em></span> <dd> <p class="para"> The seeked offset. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">whence</code></em></span> <dd> <p class="para"> <em><code class="parameter">whence</code></em> values are: <ul class="simplelist"> <li class="member"><strong><code>SEEK_SET</code></strong> - Set position equal to <em><code class="parameter">offset</code></em> bytes.</li> <li class="member"><strong><code>SEEK_CUR</code></strong> - Set position to current location plus <em><code class="parameter">offset</code></em>.</li> </ul> </p> <p class="para"> If <em><code class="parameter">whence</code></em> is not specified, it is assumed to be <strong><code>SEEK_SET</code></strong>. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.gzseek-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Upon success, returns 0; otherwise, returns -1. Note that seeking past EOF is not considered an error. </p> </div> <div class="refsect1 examples" id="refsect1-function.gzseek-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-824"> <p><strong>Example #1 <span class="function"><strong>gzseek()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$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">'r'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">gzseek</span><span style="color: #007700">(</span><span style="color: #0000BB">$gz</span><span style="color: #007700">,</span><span style="color: #0000BB">2</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">gzgetc</span><span style="color: #007700">(</span><span style="color: #0000BB">$gz</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.gzseek-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.gztell.html" class="function" rel="rdfs-seeAlso">gztell()</a> - Tell gz-file pointer read/write position</span></li> <li class="member"> <span class="function"><a href="function.gzrewind.html" class="function" rel="rdfs-seeAlso">gzrewind()</a> - Rewind the position of 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.gzrewind.html">gzrewind</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.gztell.html">gztell</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>