[PHP 7.4] Updated way to disable the fgetcsv/fputcsv escape character

From PHP 7.4, the recommended way to disable the escape character for fgetcsv() and fputcsv() is an empty string, instead of "\0".
Discussed here: https://github.com/php/php-src/pull/3515
This commit is contained in:
Adrien Loison 2019-07-20 21:02:03 +02:00 committed by Adrien Loison
parent 1bbfd45b82
commit 2716d7eeed

View File

@ -90,7 +90,7 @@ class GlobalFunctionsHelper
// To fix that, simply disable the escape character.
// @see https://bugs.php.net/bug.php?id=43225
// @see http://tools.ietf.org/html/rfc4180
$escapeCharacter = "\0";
$escapeCharacter = PHP_VERSION_ID >= 70400 ? '' : "\0";
return fgetcsv($handle, $length, $delimiter, $enclosure, $escapeCharacter);
}
@ -111,7 +111,7 @@ class GlobalFunctionsHelper
// To fix that, simply disable the escape character.
// @see https://bugs.php.net/bug.php?id=43225
// @see http://tools.ietf.org/html/rfc4180
$escapeCharacter = "\0";
$escapeCharacter = PHP_VERSION_ID >= 70400 ? '' : "\0";
return fputcsv($handle, $fields, $delimiter, $enclosure, $escapeCharacter);
}