Susantha7
Susantha7

Reputation: 936

feof function not returning false before the end of file

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
---------------------

Upvotes: 0

Views: 616

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799082

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

Upvotes: 1

Related Questions