Funkcja PHP feof ()
Definicja i Wykorzystanie
Czy feof () funkcja sprawdza osiągnięciu końca pliku (EOF).
W przypadku wystąpienia błędu lub wskaźnik pliku na końcu pliku (EOF) zwraca TRUE, w przeciwnym wypadku zwraca FALSE.
gramatyka
feof(file)
参数 | 描述 |
---|---|
file | 必需。规定要检查的打开文件。 |
Porady i wskazówki
Wskazówka: feof function ()przemierzać długość nieznanego danych jest przydatna.
Przykłady
<?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);
?>
Powyższy kod wyjścia będzie:
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.
Kompletna instrukcja Reference System plików PHP