Edit report at https://bugs.php.net/bug.php?id=62004&edit=1

 ID:                 62004
 Comment by:         carloschilazo at gmail dot com
 Reported by:        don dot binda at verizon dot net
 Summary:            SplFileObject: fgets after seek returns wrong line
 Status:             Open
 Type:               Bug
 Package:            SPL related
 Operating System:   Windows Server 2003
 PHP Version:        5.4.0
 Block user comment: N
 Private report:     N

 New Comment:

Based on documentation, it says that fgets Returns:

Returns a string containing the NEXT line from the file

wouldn't that explain?


Previous Comments:
------------------------------------------------------------------------
[2012-05-17 14:35:16] don dot binda at verizon dot net

Fixing version

------------------------------------------------------------------------
[2012-05-11 13:59:04] don dot binda at verizon dot net

Description:
------------
This is occurring in 5.4.0, although 5.4.x isn't an option under version.

Appears to be related to (or same as) 46569:

Calling fgets() after seek() to any non-zero line returns one line later than 
expected. seek(0) works fine and calling current() instead of fgets() also 
works correctly.

Test script:
---------------
Source file (temp.txt):
Line 1
Line 2
Line 3
Line 4

Code:
$f = new SplFileObject('temp.txt');
$f->seek(0);
echo $f->fgets();
$f->seek(1);
echo $f->fgets();
$f->seek(2);
echo $f->fgets();

Expected result:
----------------
Line 1
Line 2
Line 3

Actual result:
--------------
Line 1
Line 3
Line 4


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62004&edit=1

Reply via email to