|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-08-26 13:20 UTC] cmb@php.net
-Summary: escape parameter in fgetcsv() is always ignored
+Summary: escape parameter in fgetcsv() is sometimes ignored
-Status: Open
+Status: Verified
[2016-08-26 13:20 UTC] cmb@php.net
[2018-02-15 14:43 UTC] cmb@php.net
-Status: Verified
+Status: Assigned
-Type: Bug
+Type: Documentation Problem
-Assigned To:
+Assigned To: cmb
[2018-02-15 14:43 UTC] cmb@php.net
[2018-02-15 17:04 UTC] cmb@php.net
[2018-02-15 17:04 UTC] cmb@php.net
-Status: Assigned
+Status: Closed
[2018-02-15 17:04 UTC] cmb@php.net
[2020-02-07 06:05 UTC] phpdocbot@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 20:00:01 2025 UTC |
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] => )