PHP FEOF()関数
定義と使用法
FEOF()関数のチェックは、ファイルの終わり(EOF)に達しているされています。
エラーが発生した場合、またはファイルの末尾にファイルポインタ場合(EOF)それ以外の場合はFALSEを返し、TRUEを返します。
文法
feof(file)
参数 | 描述 |
---|---|
file | 必需。规定要检查的打开文件。 |
ヒントと注意事項
ヒント:不明なデータの長さを横断するFEOF()関数が便利です。
例
<?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);
?>
意志出力上のコード:
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.
PHPファイルシステムリファレンスマニュアルを完了