Bug #68466 [NEW]: Iterating SplFileObject shows empty line at end of file
| From: | tim_siebels_aurich at yahoo dot de | Date: | Thu, 20 Nov 2014 20:48:44 +0000 |
| Subject: | Bug #68466 [NEW]: Iterating SplFileObject shows empty line at end of file | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-188719@lists.php.net to get a copy of this message | ||
From: tim_siebels_aurich at yahoo dot de
Operating system:
PHP version: 5.6.3
Package: SPL related
Bug Type: Bug
Bug description:Iterating SplFileObject shows empty line at end of file
Description:
------------
Iterating over a SplFileObject differs from using fopen() and friends.
SplFileObject is supposed to be an object oriented interface for the
file handling functions. Their output shouldn't be different.
Test script:
---------------
<?php
$o = new SplFileObject(__FILE__);
foreach($o as $key=>$val) {
var_dump($val);
}
/*
Should be the same as
$h = fopen(__FILE__, 'r');
while(!feof($h)) {
var_dump(fgets($h));
}
*/
Expected result:
----------------
string(3) "<?
"
string(34) "$o = new SplFileObject(__FILE__);
"
string(1) "
"
string(28) "foreach($o as $key=>$val) {
"
string(18) " var_dump($val);
"
string(2) "}
"
bool(false)
Actual result:
--------------
<?php
$o = new SplFileObject(__FILE__);
foreach($o as $key=>$val) {
var_dump($val);
}
--
Edit bug report at https://bugs.php.net/bug.php?id=68466&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=68466&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=68466&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=68466&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=68466&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=68466&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=68466&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=68466&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=68466&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=68466&r=support
Expected behavior: https://bugs.php.net/fix.php?id=68466&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=68466&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=68466&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=68466&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68466&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=68466&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=68466&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=68466&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68466&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=68466&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=68466&r=mysqlcfg