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.

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

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?