mirror of
https://github.com/php/php-src.git
synced 2025-08-19 08:49:28 +02:00

Normalize the behavior between the file functions and those on SplFileObject. Be consistent about throwing regardless of whether the delimiter etc is empty or has too many characters. I don't think it's worthwhile to distinguish these cases. Back when we looked into this originally, there was some hope that we might want to add support for multiple-character delimiter etc, but after a cursory look, I really don't think this is going to happen (for fputcsv maybe, but for fgetcsv this just makes an already broken function much more complicated.) Closes GH-6188.
21 lines
502 B
PHP
21 lines
502 B
PHP
--TEST--
|
|
SplFileObject::fgetcsv with alternative delimiter
|
|
--FILE--
|
|
<?php
|
|
$fp = fopen('SplFileObject__fgetcsv8.csv', 'w+');
|
|
fwrite($fp, '"aaa","b""bb","ccc"');
|
|
fclose($fp);
|
|
|
|
$fo = new SplFileObject('SplFileObject__fgetcsv8.csv');
|
|
try {
|
|
var_dump($fo->fgetcsv(',', '"', 'invalid'));
|
|
} catch (ValueError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
?>
|
|
--CLEAN--
|
|
<?php
|
|
unlink('SplFileObject__fgetcsv8.csv');
|
|
?>
|
|
--EXPECT--
|
|
SplFileObject::fgetcsv(): Argument #3 ($escape) must be empty or a single character
|