如果文件指针到了 eof 或者出错时则返回 true,否则返回一个错误,包括 socket 超时,其它情况则返回 false.
语法:feof(file)
参数 描述
file 必需,规定要检查的打开文件.
说明:file 参数是一个文件指针,这个文件指针必须有效,并且必须指向一个由 fopen() 或 fsockopen() 成功打开,但还没有被 fclose() 关闭的文件.
立即学习“PHP免费学习笔记(深入)”;
PHP实例代码如下:
zuojiankuohaophpcn?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);
?>
<?php
$fh = fopen("/home/www.phpfensi.com/data/users.txt", "rt");
while (!feof($fh)) echo fgets($fh);
fclose($fh);
?>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号