首页 > php函数 > php feof函数

php feof函数

如果文件指针到了 EOF 或者出错时则返回 TRUE,否则返回一个错误(包括 socket 超时),其它情况则返回 FALSE。

 

定义和用法
feof() 函数检测是否已到达文件末尾 (eof)。

如果文件指针到了 eof 或者出错时则返回 true,否则返回一个错误(包括 socket 超时),其它情况则返回 false。

语法
feof(file)参数 描述
file 必需。规定要检查的打开文件。

说明
file 参数是一个文件指针。这个文件指针必须有效,并且必须指向一个由
document.write(document.location)() 或 fsockopen() 成功打开(但还没有被 fclose() 关闭)的文件。

 


php教程
// if file can not be read or doesn't exist fopen function returns false
$file = @fopen("no_such_file", "r");
// false from fopen will issue warning and result in infinite loop here
while (!feof($file)) {
}
fclose($file);
?>


$fh = fopen("/home/www.php100.com/data/users.txt", "rt");
while (!feof($fh)) echo fgets($fh);
fclose($fh);
?>


文章网址:http://www.phprm.com/function/php1004532.html

随意转载^^但请附上教程地址。

标签:none

发表留言