<?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 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.fseek.php',
    1 => 'fseek',
    2 => 'Sposta un puntatore sul file',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'Filesystem Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.fscanf.php',
    1 => 'fscanf',
  ),
  'next' => 
  array (
    0 => 'function.fstat.php',
    1 => 'fstat',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'it',
    '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">Sposta un puntatore sul file</span></p>

   </div>
   <div class="refsect1 unknown-604" id="refsect1-function.fseek-unknown-604">
    <h3 class="title">Descrizione</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">$handle</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"> = ?</span></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

    <p class="para rdfs-comment">
     Imposta l&#039;indicatore di posizione del file riferito da
     <code class="parameter">handle</code>. La nuova posizione, misurata in byte
     dall&#039;inizio del file, si ottiene aggiungendo
     <code class="parameter">offset</code> alla posizione specificata da
     <code class="parameter">whence</code>, i cui valori sono definiti come 
     segue:
     <ul class="simplelist">
      <li><strong><code><a href="filesystem.constants.php#constant.seek-set">SEEK_SET</a></code></strong> - Imposta la posizione uguale a <code class="parameter">offset</code> byte.</li> 
      <li><strong><code><a href="filesystem.constants.php#constant.seek-cur">SEEK_CUR</a></code></strong> - Imposta la posizione alla attuale più <code class="parameter">offset</code>.</li> 
      <li><strong><code><a href="filesystem.constants.php#constant.seek-end">SEEK_END</a></code></strong> - Imposta la posizione alla fine del file più <code class="parameter">offset</code>.
      (To move to a position before the end-of-file, you need to pass a negative 
      value in <code class="parameter">offset</code>.)</li>
     </ul>
    </p>
    <p class="para">
    Se <code class="parameter">whence</code> non viene specificato, viene assunto come
    <strong><code><a href="filesystem.constants.php#constant.seek-set">SEEK_SET</a></code></strong>.
    </p>
    <p class="para">
     In caso di successo, restituisce 0; altrimenti, restituisce -1. Nota che spostarsi oltre
     EOF non è considerato un errore.
    </p>
    <p class="para">
     <div class="example" id="example-1">
      <p><strong>Example #1 Esempio di uso di <span class="function"><strong>fseek()</strong></span></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">);<br /><br /></span><span style="color: #FF8000">// Lettura di qualche dato<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">// si torna ad inizio file<br />// come 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>
    <p class="para">
     Non può essere usato su puntatori a file restituiti da
     <span class="function"><a href="function.fopen.php" class="function">fopen()</a></span> se è in uso il formato 
     &quot;http://&quot; o &quot;ftp://&quot;. <span class="function"><strong>fseek()</strong></span> da anche risultati non definiti 
    per stream in modalità append-only (aperti con il flag &quot;a&quot;).
    </p>
    <blockquote class="note"><p><strong class="note">Nota</strong>: 
     <p class="para">
      L&#039;argomento <code class="parameter">whence</code> è stato aggiunto dopo PHP 4.0.0.
     </p>
    </p></blockquote>
    <p class="para">
     Vedere anche <span class="function"><a href="function.ftell.php" class="function">ftell()</a></span> e
     <span class="function"><a href="function.rewind.php" class="function">rewind()</a></span>.
    </p>
   </div>

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