PHP feof() 函數(shù)
PHP feof() 函數(shù)

定義和用法
feof() 函數(shù)檢查是否已到達文件末尾(EOF)。
如果出錯或者文件指針到了文件末尾(EOF)則返回 TRUE,否則返回 FALSE。
語法
feof(file)
參數(shù) | 描述 |
---|---|
file | 必需。規(guī)定要檢查的打開文件。 |
提示和注釋
提示:feof() 函數(shù)對遍歷長度未知的數(shù)據(jù)很有用。
實例
以下實例輸出文件的每一行,直到最后一行結束:
實例
<?php
$file = fopen("test.txt", "r");
// 輸出文件的每一行直到文件結尾
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.

相關文章
- PHP 安裝
- PHP Switch 語句
- PHP 超級全局變量
- PHP 錯誤處理
- PHP array_chunk() 函數(shù)
- PHP array_combine() 函數(shù)
- PHP array_count_values() 函數(shù)
- PHP array_key_exists() 函數(shù)
- PHP array_product() 函數(shù)
- PHP array_reverse() 函數(shù)
- PHP array_slice() 函數(shù)
- PHP array_uintersect_uassoc() 函數(shù)
- PHP array_values() 函數(shù)
- PHP end() 函數(shù)
- PHP next() 函數(shù)
- PHP pos() 函數(shù)
- PHP reset() 函數(shù)
- PHP uasort() 函數(shù)
- PHP HTTP 函數(shù)
- PHP 雜項 函數(shù)