Bug #67566 [Opn->Ver]: escape parameter in fgetcsv() is sometimes ignored
| From: | cmb@php.net | Date: | Fri, 26 Aug 2016 13:20:53 +0000 |
| Subject: | Bug #67566 [Opn->Ver]: escape parameter in fgetcsv() is sometimes ignored | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-203576@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67566&edit=1
ID: 67566
Updated by: cmb@php.net
Reported by: sebastian dot schmidt at meap dot de
-Summary: escape parameter in fgetcsv() is always ignored
+Summary: escape parameter in fgetcsv() is sometimes ignored
-Status: Open
+Status: Verified
Type: Bug
Package: Filesystem function related
Operating System: Debian 6.0.7
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Confirmed: <https://3v4l.org/ZRbQa>. Note that the
$escape
parameter is not always ignored, though, see bug #70491.
Previous Comments:
------------------------------------------------------------------------
[2014-07-04 08:10:35] sebastian dot schmidt at meap dot de
Description:
------------
It seem that the 5th parameter $escape in fgetcsv() function is completly ignored when executing the
function. I tested the script on 3 different minor php version (5.3.5, 5.4.11 ans 5.5.7) all with
the same result.
If you try to set the escape character to any other character than " (double-quote) php totally
ignores the parameter and still uses the double-quote.
Also this behavior show that the default escape character, which should be the backslash as outlined
in the documentation, is the double-quote.
Test script:
---------------
<?php
$fileContents = <<<EOD
"quote \"testing\"",""
"quote ""testing""",""
"quote \,testing\,",""
EOD;
$handle = fopen('php://memory', 'w');
fwrite($handle, $fileContents);
fseek($handle, 0);
while(!feof($handle))
{
$test = fgetcsv($handle, 0, ',', '"', '\\');
print_r($test);
}
?>
Expected result:
----------------
Array
(
[0] => quote "testing"
[1] =>
)
Array
(
[0] => quote ""testing""
[1] =>
)
Array
(
[0] => quote \,testing\,
[1] =>
)
Actual result:
--------------
Array
(
[0] => quote \"testing\"
[1] =>
)
Array
(
[0] => quote "testing"
[1] =>
)
Array
(
[0] => quote \,testing\,
[1] =>
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67566&edit=1