php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #42202 fputcsv() inserts a new line character at the end of string
Submitted: 2007-08-03 12:13 UTC Modified: 2007-08-16 09:01 UTC
From: nikhil dot gupta at in dot ibm dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 5CVS-2007-08-03 (CVS) OS: Linux, Windows
Private report: No CVE-ID: None
 [2007-08-03 12:13 UTC] nikhil dot gupta at in dot ibm dot com
Description:
------------
fputcsv() inserts a newline character at the end of string. This behaviour is not seen in the documentation. This happens for both php5 and php6 on windows as well as on RHEL.

Reproduce code:
---------------
<?php
$list = array ('aaa,bbb');
$fp = fopen("file.tmp", 'w');
var_dump(fputcsv($fp, $list));
var_dump( filesize("file.tmp") );
var_dump( file_get_contents("file.tmp") );
fclose($fp);
?> 


Expected result:
----------------
int(9)
int(9)
string(9) ""aaa,bbb""


Actual result:
--------------
int(10)
int(10)
string(10) ""aaa,bbb"
"


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-04 14:10 UTC] jani@php.net
This is the correct behaviour. Reclassified as docu bug.
 [2007-08-16 09:01 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"fputcsv() formats a line as CSV and write it (terminated by a newline) to the specified file"
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 05 12:01:34 2025 UTC