PHP - Fonction feof ()

La fonction feof () vérifie si la "fin de fichier" (EOF) est atteinte. Cette fonction peut retourner true si une erreur se produit ou EOF a atteint, sinon elle peut renvoyer false.

Syntaxe

bool feof ( resource $handle )

La fonction feof () peut être utile pour parcourir des données de longueur inconnue.

Exemple

<?php
   $file = fopen("/PhpProject/sample.txt", "r");
   
   // Output a line of the file until the end is reached
   while(! feof($file)) {
      echo fgets($file);
   }
   fclose($file);
?>

Production

tutorialspoint
tutorix