php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47959 stream_get_line
Submitted: 2009-04-13 11:53 UTC Modified: 2009-04-13 12:02 UTC
From: z at szaboz dot com Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.2.9 OS: debian linux kernel 2.6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: z at szaboz dot com
New email:
PHP Version: OS:

 

 [2009-04-13 11:53 UTC] z at szaboz dot com
Description:
------------
this functions seems ignores the very first line starts with '#' sign

Reproduce code:
---------------
$fstr = fopen(myfile.txt,"r");

while(!feof($fstr)) {

	$r[] = stream_get_line($fstr,400,"\n");

}


the myfile .txt:
#simple comment

default_size = 400
my_data = testdata
new_setup_dir = /root/master

#another comment

myIint = 45345
one_more_setup   = value

this_variable = false

set_new_class = mycalss

Expected result:
----------------
array(13) {  
  [0]=>
  string(0) "#simple comment"
  [1]=>
  string(0) ""
  [2]=>
  string(18) "default_size = 400"
  [3]=>
  string(18) "my_data = testdata"
  [4]=>
  string(28) "new_setup_dir = /root/master"
  [5]=>
  string(0) ""
  [6]=>
  string(16) "#another comment"
  [7]=>
  string(0) ""
  [8]=>
  string(15) "my_int = 45345"
  [9]=>
  string(24) "one_more_setup   = value"
  [10]=>
  string(0) ""
  [11]=>
  string(21) "this_variable = false"
  [12]=>
  string(0) ""
  [13]=>
  string(23) "set_new_class = mycalss"
}


Actual result:
--------------
array(13) {

  [0]=>
  string(0) ""
  [1]=>
  string(18) "default_size = 400"
  [2]=>
  string(18) "my_data = testdata"
  [3]=>
  string(28) "new_setup_dir = /root/master"
  [4]=>
  string(0) ""
  [5]=>
  string(16) "#another comment"
  [6]=>
  string(0) ""
  [7]=>
  string(15) "my_int = 45345"
  [8]=>
  string(24) "one_more_setup   = value"
  [9]=>
  string(0) ""
  [10]=>
  string(21) "this_variable = false"
  [11]=>
  string(0) ""
  [12]=>
  string(23) "set_new_class = mycalss"
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-13 12:02 UTC] jani@php.net
Proper script like this: 

<?php

$fstr = fopen("myfile.txt","r");
$r = array();

while(!feof($fstr)) {
  $r[] = stream_get_line($fstr,400,"\n");
}

var_dump($r);

?>

Works just fine -> bogus.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 02 18:01:31 2024 UTC