mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +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.
26 lines
537 B
PHP
26 lines
537 B
PHP
--TEST--
|
|
SplFileObject::fgetcsv with alternative delimiter
|
|
--FILE--
|
|
<?php
|
|
$fp = fopen('SplFileObject__fgetcsv5.csv', 'w+');
|
|
fputcsv($fp, array(
|
|
'field1',
|
|
'field2',
|
|
'field3',
|
|
5
|
|
), ',', '"');
|
|
fclose($fp);
|
|
|
|
$fo = new SplFileObject('SplFileObject__fgetcsv5.csv');
|
|
try {
|
|
var_dump($fo->fgetcsv(',', 'invalid'));
|
|
} catch (ValueError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
?>
|
|
--CLEAN--
|
|
<?php
|
|
unlink('SplFileObject__fgetcsv5.csv');
|
|
?>
|
|
--EXPECT--
|
|
SplFileObject::fgetcsv(): Argument #2 ($enclosure) must be a single character
|