php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42167 fgetcsv gives different output on php6 compared to php5
Submitted: 2007-08-01 14:32 UTC Modified: 2008-02-06 02:58 UTC
From: nikhil dot gupta at in dot ibm dot com Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 6CVS-2007-08-01 (snap) OS: Linux
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: nikhil dot gupta at in dot ibm dot com
New email:
PHP Version: OS:

 

 [2007-08-01 14:32 UTC] nikhil dot gupta at in dot ibm dot com
Description:
------------
fgetcsv() gives different output on php6 compared to php6 on linux.

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

$filename = dirname(__FILE__) . '/fgetcsv1.tmp';

$file_handle = fopen($filename, "w+" );
$delimiter = '\\';
$csv_field = 'water\\"fruit"\\"air"';

fwrite($file_handle, $csv_field . "\n");

rewind($file_handle);

var_dump( fgetcsv($file_handle, 1024, $delimiter ) );
// close the file
fclose($file_handle);
//delete file
unlink($filename);

?>


Expected result:
----------------
according to php5 the output is:

array(3) {
  [0]=>
  string(5) "water"
  [1]=>
  string(5) "fruit"
  [2]=>
  string(3) "air"
}


Actual result:
--------------
Output on php6 is:

array(1) {
  [0]=>
  string(19) "water\"fruit"\"air""
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-01 14:35 UTC] nikhil dot gupta at in dot ibm dot com
The same difference is observed on Windows also.
 [2007-08-06 13:14 UTC] nikhil dot gupta at in dot ibm dot com
There is a typo in the Description. Here is the correct one:
fgetcsv() gives different output on php6 compared to php5 on linux. The output on php5 is correct.
 [2008-02-05 15:44 UTC] msaraujo@php.net
I have reproduced the code in PHP 6 and PHP 5.2.5, got the same behavior as you got.
 [2008-02-06 02:58 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-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 18:01:34 2025 UTC