PHP feof() 函數(shù)

2018-11-21 15:58 更新

PHP feof() 函數(shù)


PHP Filesystem 參考手冊 完整的 PHP Filesystem 參考手冊

定義和用法

feof() 函數(shù)檢查是否已到達(dá)文件末尾(EOF)。

如果出錯(cuò)或者文件指針到了文件末尾(EOF)則返回 TRUE,否則返回 FALSE。

語法

feof(file)

參數(shù) 描述
file 必需。規(guī)定要檢查的打開文件。


提示和注釋

提示:feof() 函數(shù)對遍歷長度未知的數(shù)據(jù)很有用。


實(shí)例

<?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);
?>

上面的代碼將輸出:

Hello, this is a test file.
There are three lines here.
This is the last line.


PHP Filesystem 參考手冊 完整的 PHP Filesystem 參考手冊
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號