<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.filesystem.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.fseek.php',
    1 => 'fseek',
    2 => 'Seeks on a file pointer',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'Функції Файлової Системи',
  ),
  'prev' => 
  array (
    0 => 'function.fscanf.php',
    1 => 'fscanf',
  ),
  'next' => 
  array (
    0 => 'function.fstat.php',
    1 => 'fstat',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/filesystem/functions/fseek.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.fseek" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">fseek</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">fseek</span> &mdash; <span class="dc-title">Seeks on a file pointer</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.fseek-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>fseek</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span> <code class="parameter">$stream</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$offset</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$whence</code><span class="initializer"> = <strong><code><a href="filesystem.constants.php#constant.seek-set">SEEK_SET</a></code></strong></span></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="para rdfs-comment">
   Sets the file position indicator for the file referenced by
   <code class="parameter">stream</code>. The new position, measured in bytes
   from the beginning of the file, is obtained by adding
   <code class="parameter">offset</code> to the position specified by
   <code class="parameter">whence</code>.
  </p>
  <p class="para">
   In general, it is allowed to seek past the end-of-file; if data is then
   written, reads in any unwritten region between the end-of-file and the
   sought position will yield bytes with value 0. However, certain streams
   may not support this behavior, especially when they have an underlying
   fixed size storage.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.fseek-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">stream</code></dt>
     <dd>
      <p class="para">Вказівник файлової системи типу
<span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>, якого повертає функція
<span class="function"><a href="function.fopen.php" class="function">fopen()</a></span>.</p>
     </dd>
    
    
     <dt><code class="parameter">offset</code></dt>
     <dd>
      <p class="para">
       The offset.
      </p>
      <p class="para">
       To move to a position before the end-of-file,
       a negative value in the <code class="parameter">offset</code> must be passed and
       the <code class="parameter">whence</code> parameter must be set
       to <strong><code><a href="filesystem.constants.php#constant.seek-end">SEEK_END</a></code></strong>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">whence</code></dt>
     <dd>
      <p class="para">
       <code class="parameter">whence</code> values are:
       <ul class="simplelist">
        <li><strong><code><a href="filesystem.constants.php#constant.seek-set">SEEK_SET</a></code></strong> - Set position equal to <code class="parameter">offset</code> bytes from the start of the file.</li>
        <li><strong><code><a href="filesystem.constants.php#constant.seek-cur">SEEK_CUR</a></code></strong> - Set position to current location plus <code class="parameter">offset</code> bytes.</li>
        <li><strong><code><a href="filesystem.constants.php#constant.seek-end">SEEK_END</a></code></strong> - Set position to end-of-file plus <code class="parameter">offset</code> bytes.</li>
       </ul>
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.fseek-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Upon success, returns <code class="literal">0</code>;
   otherwise, returns <code class="literal">-1</code>.
  </p>
  <div class="warning"><strong class="warning">Увага</strong>
   <p class="simpara">
    This function was created to imitate the C language function of the same
    name. Please pay attention to the return values as they differ from what
    one would expect in PHP.
   </p>
  </div>
 </div>


 <div class="refsect1 examples" id="refsect1-function.fseek-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 <span class="function"><strong>fseek()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$fp </span><span style="color: #007700">= </span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">'somefile.txt'</span><span style="color: #007700">, </span><span style="color: #DD0000">'r'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// read some data<br /></span><span style="color: #0000BB">$data </span><span style="color: #007700">= </span><span style="color: #0000BB">fgets</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">, </span><span style="color: #0000BB">4096</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// move back to the beginning of the file<br />// same as rewind($fp);<br /></span><span style="color: #0000BB">fseek</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.fseek-notes">
  <h3 class="title">Примітки</h3>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    If you have opened the file in append (<code class="literal">a</code> or
    <code class="literal">a+</code>) mode, any data you write to the file will always be
    appended, regardless of the file position, and the result of calling
    <span class="function"><strong>fseek()</strong></span> will be undefined.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    Not all streams support seeking. For those that do not support seeking,
    forward seeking from the current position is accomplished by reading
    and discarding data; other forms of seeking will fail.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.fseek-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.ftell.php" class="function" rel="rdfs-seeAlso">ftell()</a> - Returns the current position of the file read/write pointer</span></li>
    <li><span class="function"><a href="function.rewind.php" class="function" rel="rdfs-seeAlso">rewind()</a> - Rewind the position of a file pointer</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>