note 107449 added to function.feof
| From: | dewi at dewimorgan dot com | Date: | Thu, 09 Feb 2012 23:17:13 +0000 |
| Subject: | note 107449 added to function.feof | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186043@lists.php.net to get a copy of this message | ||
Return values in the documentation are incorrectly stated. It says:
Returns TRUE if the file pointer is at EOF or an error occurs (including socket timeout); otherwise
returns FALSE.
Correct text would be more like:
Returns FALSE if no filehandle was passed;
returns NULL if no filehandle was passed;
returns TRUE if the file pointer is at EOF or an error occurs (including socket timeout);
otherwise returns FALSE.
As an example, running the following from the commandline:
php -r 'echo
"Empty: ".var_export(feof(), true)."\n".
"Null: ".var_export(feof(NULL), true)."\n".
"Undefined: ".var_export(feof($undef), true)."\n"
;'
This will output:
PHP Warning: Wrong parameter count for feof() in Command line code on line 1
PHP Warning: feof(): supplied argument is not a valid stream resource in Command line code on line
1
PHP Warning: feof(): supplied argument is not a valid stream resource in Command line code on line
1
Empty: NULL
Null: false
Undefined: false
This can, as other commenters have reported, result in infinite loops and massive PHP error
logfiles, if the file handle returned by fopen() is invalid for any reason.
----
Server IP: 208.69.120.55
Probable Submitter: 72.182.42.28
----
Manual Page -- http://www.php.net/manual/en/function.feof.php
Edit -- https://master.php.net/note/edit/107449
Del: integrated -- https://master.php.net/note/delete/107449/integrated
Del: useless -- https://master.php.net/note/delete/107449/useless
Del: bad code -- https://master.php.net/note/delete/107449/bad+code
Del: spam -- https://master.php.net/note/delete/107449/spam
Del: non-english -- https://master.php.net/note/delete/107449/non-english
Del: in docs -- https://master.php.net/note/delete/107449/in+docs
Del: other reasons-- https://master.php.net/note/delete/107449
Reject -- https://master.php.net/note/reject/107449
Search -- https://master.php.net/manage/user-notes.php