Bug #68466 [Com]: Iterating SplFileObject shows empty line at end of file
| From: | master dot training365 at gmail dot com | Date: | Fri, 11 Feb 2022 21:56:41 +0000 |
| Subject: | Bug #68466 [Com]: Iterating SplFileObject shows empty line at end of file | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-239692@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68466&edit=1
ID: 68466
Comment by: master dot training365 at gmail dot com
Reported by: tim_siebels_aurich at yahoo dot de
Summary: Iterating SplFileObject shows empty line at end of
file
Status: Open
Type: Bug
Package: SPL related
PHP Version: 5.6.3
Block user comment: N
Private report: N
New Comment:
http://git.province.namur.be/Wikiew/Techi/wiki/Cloning
Previous Comments:
------------------------------------------------------------------------
[2022-02-11 21:49:55] master dot training365 at gmail dot com
http://git.province.namur.be/glintpost
------------------------------------------------------------------------
[2022-02-11 21:43:08] master dot training365 at gmail dot com
https://www.goodreads.com/questions/500912-i-loved-this-book-until-the-last-page
------------------------------------------------------------------------
[2022-02-11 21:39:23] master dot training365 at gmail dot com
https://pastelink.net/28fpp938
------------------------------------------------------------------------
[2016-06-21 22:39:02] cmb@php.net
> I see why it is good to have it when iterating over the
> SplFileObject. Otherwise every last line would be false.
> However, I don't see why they should be different. I expect them
> to be the same. They provide the same functionality and even the
> same names.
So you really think the more useful behavior should be changed for
the sake of consistency with rather low-level (C'ish) behavior?
I'd rather change the names of the methods instead. Neither is
obviously something that can be easily done with regard to
backward compatibility, though.
------------------------------------------------------------------------
[2014-11-23 12:06:25] tim_siebels_aurich at yahoo dot de
To (1):
fmargaine also provided an equivalent snippet, that doesn't match the output.
To (2):
Of course they do, that's why I opened this bug :P
I don't really understand why SplFileObject works differently.
> SplFileObject works on streams too but entire lines at a time.
SplFileObject has methods that map the name from fopen and friends.
As far as I know SplFileObject doesn't use entire lines.
I can SplFileObject::fread from it as well.
fgets() uses entire lines as well, but the output still differs.
I see why it is good to have it when iterating over the SplFileObject. Otherwise every last line
would be false.
However, I don't see why they should be different. I expect them to be the same. They provide
the same functionality and even the same names.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=68466
--
Edit this bug report at https://bugs.php.net/bug.php?id=68466&edit=1