SplFileObject_fputcsv_variation14.phpt 893 B

12345678910111213141516171819202122232425262728293031
  1. --TEST--
  2. Test fputcsv() : usage variations - with enclosure & delimiter of two chars
  3. --FILE--
  4. <?php
  5. /* Testing fputcsv() to write to a file when default enclosure value and delimiter
  6. of two chars is provided and file is opened in read only mode */
  7. echo "*** Testing fputcsv() : with enclosure & delimiter of two chars and file opened in read mode ***\n";
  8. $fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv_variation14.csv', 'w');
  9. try {
  10. var_dump($fo->fputcsv(array('water', 'fruit'), ',,', '""'));
  11. } catch (ValueError $e) {
  12. echo $e->getMessage(), "\n";
  13. }
  14. unset($fo);
  15. echo "Done\n";
  16. ?>
  17. --CLEAN--
  18. <?php
  19. $file = __DIR__ . '/SplFileObject_fputcsv_variation14.csv';
  20. unlink($file);
  21. ?>
  22. --EXPECT--
  23. *** Testing fputcsv() : with enclosure & delimiter of two chars and file opened in read mode ***
  24. SplFileObject::fputcsv(): Argument #3 ($enclosure) must be a single character
  25. Done