() La fonction PHP
Définition et utilisation
Y feof () vérifie la fonction ont atteint la fin du fichier (EOF).
Si une erreur se produit, ou le pointeur de fichier à la fin du fichier (EOF) retourne TRUE, sinon elle retourne FALSE.
grammaire
feof(file)
参数 | 描述 |
---|---|
file | 必需。规定要检查的打开文件。 |
Trucs et astuces
Conseil: la fonction feof ()pour parcourir la longueur des données utiles est inconnue.
Exemples
<?php
$file = fopen("test.txt", "r");
//Output a line of the file until the end is reached
while(! feof($file))
{
echo fgets($file). "<br />";
}
fclose($file);
?>
$file = fopen("test.txt", "r");
//Output a line of the file until the end is reached
while(! feof($file))
{
echo fgets($file). "<br />";
}
fclose($file);
?>
Le code ci-dessus va afficher:
Hello, this is a test file.
There are three lines here.
This is the last line.
There are three lines here.
This is the last line.
Remplissez Manuel PHP Référence Filesystem