Doc #61048 [Com]: fgetcsv() length of 0 DOES NOT mean unlimited maximum line length
| From: | cmbecker69 at gmx dot de | Date: | Thu, 13 Feb 2014 01:05:48 +0000 |
| Subject: | Doc #61048 [Com]: fgetcsv() length of 0 DOES NOT mean unlimited maximum line length | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-10981@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=61048&edit=1
ID: 61048
Comment by: cmbecker69 at gmx dot de
Reported by: blajoie55 at gmail dot com
Summary: fgetcsv() length of 0 DOES NOT mean unlimited
maximum line length
Status: Open
Type: Documentation Problem
Package: Documentation problem
Operating System: Linux
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Confirmed by testing on Win7. PHP 5.0.4 (and 5.0.5) treats
$length=0 as $length=1, while PHP 5.1.0 treats it as infinite
(well, at least 131073).
Previous Comments:
------------------------------------------------------------------------
[2012-02-12 05:20:41] phpmpan at mpan dot pl
Confirmed. 5.0.4 uses code from r181491 (in 5.0 branch), which sets length to 1 if 0 is passed as
the second argument. The behaviour described by the documentation was introduced by r181490 (in
5.1).
Therefore the documentation should be changed to:
"Omitting this parameter (or setting it to 0 in PHP 5.1.0 and later) the maximum line length is
not limited, which is slightly slower."
------------------------------------------------------------------------
[2012-02-10 18:43:24] blajoie55 at gmail dot com
updating summary
------------------------------------------------------------------------
[2012-02-10 18:28:32] blajoie55 at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.fgetcsv#refsect1-function.fgetcsv-
parameters
---
The documentation states the following for the length parameter for fgetcsv():
"Must be greater than the longest line (in characters) to be found in the CSV
file (allowing for trailing line-end characters). It became optional in PHP 5.
Omitting this parameter (or setting it to 0 in PHP 5.0.4 and later) the maximum
line length is not limited, which is slightly slower."
This is wrong. I have a php 5.0.4 environment using fgetcsv() in a while loop as
follows:
fgetcsv($csvHandle, 0, self::DELIMITER);
And the 0 does not put no limit on the max line length, instead the fgetcsv()
call gets each individual character on the line in the file
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=61048&edit=1