<?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 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.feof.php',
    1 => 'feof',
    2 => 'Teste la fin du fichier',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'Fonctions sur les syst&egrave;mes de fichiers',
  ),
  'prev' => 
  array (
    0 => 'function.fdatasync.php',
    1 => 'fdatasync',
  ),
  'next' => 
  array (
    0 => 'function.fflush.php',
    1 => 'fflush',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/filesystem/functions/feof.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.feof" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">feof</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">feof</span> &mdash; <span class="dc-title">Teste la fin du fichier</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.feof-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>feof</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="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Teste la fin du fichier.
  </p>
 </div>

 
 <div class="refsect1 parameters" id="refsect1-function.feof-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">stream</code></dt>
     <dd>
      <p class="para">Le pointeur de fichier doit être valide et pointer
sur un fichier ouvert avec succès par <span class="function"><a href="function.fopen.php" class="function">fopen()</a></span> ou
<span class="function"><a href="function.fsockopen.php" class="function">fsockopen()</a></span> (et pas encore fermé par <span class="function"><a href="function.fclose.php" class="function">fclose()</a></span>).</p>
     </dd>
    
   </dl>
  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.feof-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Retourne <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> si le pointeur
   <code class="parameter">stream</code> est à la fin du fichier ou si
   une erreur survient (y compris les délais d&#039;attente de socket), sinon, retourne <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
  </p>
 </div>

 
 <div class="refsect1 notes" id="refsect1-function.feof-notes">
  <h3 class="title">Notes</h3>
  <div class="warning"><strong class="warning">Avertissement</strong>
   <p class="para">
    Si une connexion ouverte avec <span class="function"><a href="function.fsockopen.php" class="function">fsockopen()</a></span> n&#039;est pas fermée
    par le serveur, <span class="function"><strong>feof()</strong></span> se bloquera.
    Pour contourner ce comportement, se reporter à l&#039;exemple ci-dessous :
    <div class="example" id="example-1">
     <p><strong>Exemple #1 Gestion des délais d&#039;attente dépassés <span class="function"><strong>feof()</strong></span></strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function </span><span style="color: #0000BB">safe_feof</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">, &amp;</span><span style="color: #0000BB">$start </span><span style="color: #007700">= </span><span style="color: #0000BB">NULL</span><span style="color: #007700">) {<br /> </span><span style="color: #0000BB">$start </span><span style="color: #007700">= </span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">);<br /><br /> return </span><span style="color: #0000BB">feof</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #FF8000">/* Assumons que $fp a été précédemment ouvert par fsockopen() */<br /><br /></span><span style="color: #0000BB">$start </span><span style="color: #007700">= </span><span style="color: #0000BB">NULL</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$timeout </span><span style="color: #007700">= </span><span style="color: #0000BB">ini_get</span><span style="color: #007700">(</span><span style="color: #DD0000">'default_socket_timeout'</span><span style="color: #007700">);<br /><br />while(!</span><span style="color: #0000BB">safe_feof</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">, </span><span style="color: #0000BB">$start</span><span style="color: #007700">) &amp;&amp; (</span><span style="color: #0000BB">microtime</span><span style="color: #007700">(</span><span style="color: #0000BB">true</span><span style="color: #007700">) - </span><span style="color: #0000BB">$start</span><span style="color: #007700">) &lt; </span><span style="color: #0000BB">$timeout</span><span style="color: #007700">)<br />{<br /> </span><span style="color: #FF8000">/* Gestion */<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
     </div>

    </div>
   </p>
  </div>
  <div class="warning"><strong class="warning">Avertissement</strong>
   <p class="para">
    Si le pointeur de fichier passé n&#039;est pas valide, le résultat sera une
    boucle infinie car <span class="function"><strong>feof()</strong></span> échouera à retourner <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
    <div class="example" id="example-2">
     <p><strong>Exemple #2 Exemple avec <span class="function"><strong>feof()</strong></span> et un pointeur de fichier invalide</strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Si le fichier ne peut être lu ou n'existe pas, la fonction fopen retourne FALSE<br /></span><span style="color: #0000BB">$file </span><span style="color: #007700">= @</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">"no_such_file"</span><span style="color: #007700">, </span><span style="color: #DD0000">"r"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// FALSE issu de fopen émettra une alerte et fera que l'on aura une boucle infinie ici<br /></span><span style="color: #007700">while (!</span><span style="color: #0000BB">feof</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">)) {<br />}<br /><br /></span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
     </div>

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

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