php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42229 fgetcsv() behaves differently for a file containing '\n' with php5 and php6.
Submitted: 2007-08-07 05:54 UTC Modified: 2008-02-10 04:09 UTC
From: nikhil dot gupta at in dot ibm dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 6CVS-2007-08-07 (snap) OS: Linux, Win32-xp
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nikhil dot gupta at in dot ibm dot com
New email:
PHP Version: OS:

 

 [2007-08-07 05:54 UTC] nikhil dot gupta at in dot ibm dot com
Description:
------------
fgetcsv() behaves differently for a file which has  '\n' characters for php5 and php6. php5 output is correct because the characters are given in single quotes hence these characters will not be interpreted as newline and taken as normal characters. Hence fgetcsv() should print the characters which is happening on php5 and not on php6. 

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

$fp = fopen("file2.tmp", "w");
$csv_string = '\n';
fwrite($fp, $csv_string);
fclose($fp);

$fp = fopen("file2.tmp", "r");
var_dump( ftell($fp) );
var_dump( fgetcsv($fp) );
var_dump( ftell($fp) );
var_dump( feof($fp) );
var_dump( fseek($fp, 0, SEEK_END) );
var_dump( ftell($fp) );
var_dump( feof($fp) );
fclose($fp);
?>

Expected result:
----------------
int(0)
array(1) {
  [0]=>
  string(2) "\n"
}
int(2)
bool(true)
int(0)
int(2)
bool(true)

Actual result:
--------------
int(0)
array(0) {
}
int(2)
bool(true)
int(0)
int(2)
bool(false)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-10 04:09 UTC] felipe@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-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 09:01:28 2024 UTC