doutang6600 2014-08-12 05:14
浏览 62
已采纳

feof函数在文件结束前不返回false

i write php script for check feof function according to php.net Returns TRUE if the file pointer is at EOF or an error occurs (including socket timeout); otherwise returns FALSE. my question is there is no eturn value for feof() when there is before the end of file ?

this is my php file

<?php
$myfile = fopen("webdictionary.txt", "r") or die("Unable to open file!");
// Output one line until end-of-file


echo "----------------------<br>";
echo "end of file is ".feof($myfile)."<br>";
echo "---------------------<br>";


while(!feof($myfile))
{
   echo fgets($myfile) . " ----- "."end of file is ".feof($myfile)."<br>";
}

echo "----------------------<br>";
echo "end of file is ".feof($myfile)."<br>";
echo "---------------------<br>";

fclose($myfile)

?>

this text file(webdictionary.txt)

AJAX = Asynchronous JavaScript and XML
CSS = Cascading Style Sheets
HTML = Hyper Text Markup Language
PHP = PHP Hypertext Preprocessor
SQL= Structured Query Language SVG = Scalable Vector Graphics
XML = EXtensible Markup Language

this is php output

----------------------
end of file is 
---------------------
AJAX = Asynchronous JavaScript and XML ----- end of file is 
CSS = Cascading Style Sheets ----- end of file is 
HTML = Hyper Text Markup Language ----- end of file is 
PHP = PHP Hypertext Preprocessor ----- end of file is 
SQL = Structured Query Language ----- end of file is 
SVG = Scalable Vector Graphics ----- end of file is 
XML = EXtensible Markup Language ----- end of file is 1
----------------------
end of file is 1
---------------------
  • 写回答

1条回答 默认 最新

  • douna2917 2014-08-12 05:18
    关注

    Your question is invalid. false echos out as an empty string, and true echos out as 1.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!