php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30362 stream_get_line() not working as documented
Submitted: 2004-10-08 13:39 UTC Modified: 2005-04-05 05:00 UTC
From: uk_gavin_uk at hotmail dot com Assigned: iliaa
Status: Closed Package: Filesystem function related
PHP Version: 5.* OS: *
Private report: No CVE-ID:
 [2004-10-08 13:39 UTC] uk_gavin_uk at hotmail dot com
Description:
------------
- Downloaded and using php-5.0.2-Win32.zip from www.php.net
- Confirmed md5 hash

using stream_get_line() on a file I get data returned to me but not in the manner expected or documented??  It's best you look at the Reproduce code, but it looks like the function reads up until the first instance of the delimiter specified, but on subsequent calls it ignores the delemeter and reads in the number of chars it did on the first call??  




Reproduce code:
---------------
<?php

$resource = fopen('C:/test/import/file.txt', 'rb');

for ($i = 0; ($i < 10) && !feof($resource); ++$i ) {

    $line = stream_get_line($resource, 50, $a);
    echo $line . "\n";
    
}
fclose($resource);
        
?>

FILE.TXT: 111Y111111111Y111111111Y111111111Y111111111Y111111111Y111111111Y111111111Y111111111Y111111111

Expected result:
----------------
111
111111111
111111111
111111111
111111111
111111111
111111111
111111111

Actual result:
--------------
111
Y11
111
111
1Y1
111
111
11Y
111
111

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-11 15:59 UTC] uk_gavin_uk at hotmail dot com
$a = "Y";
echo "$a as Delimeter";
-------

I edited the code a bit to reduce the size, I was trying different $a to see if it made a difference - it didnt!
 [2004-10-11 20:33 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2005-04-04 19:58 UTC] sniper@php.net
Reproduced on Linux using latest CVS HEAD. Patch did not work.
(was supposed to be fixed in PHP 5.0.4 but isn't :)

 [2005-04-05 05:00 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 17 21:01:56 2014 UTC