Bug #67566 [NEW]: escape parameter in fgetcsv() is always ignored
| From: | sebastian dot schmidt at meap dot de | Date: | Fri, 04 Jul 2014 08:10:37 +0000 |
| Subject: | Bug #67566 [NEW]: escape parameter in fgetcsv() is always ignored | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-186460@lists.php.net to get a copy of this message | ||
From: sebastian dot schmidt at meap dot de
Operating system: Debian 6.0.7
PHP version: Irrelevant
Package: Filesystem function related
Bug Type: Bug
Bug description:escape parameter in fgetcsv() is always ignored
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 bug report at https://bugs.php.net/bug.php?id=67566&edit=1
--