为什么 feof 与 fseek 和 fread 一起使用时返回不同的结果?

问题描述

在调试我正在实现的函数时,我注意到 feoffseekfread 一起使用时的返回结果不同,请您向我解释为什么 {{1} feof 参与时无法测试文件结尾?

fseek

输出

$file = fopen('data.txt','r');
// Do some operations on the file then seek to end of it
fseek($file,SEEK_END);
echo ftell($file) . PHP_EOL;
var_dump(feof($file));
echo '##############################################################' . PHP_EOL;

rewind($file);
while(!feof($file))
{
    fread($file,500);
}

echo ftell($file) . PHP_EOL;
var_dump(feof($file));
fclose($file);

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)