0
0

More than 3 years have passed since last update.

PHP: fputcsv: delimiter must be a single character エラー

Last updated at Posted at 2020-01-05

エラーメッセージ

PHP Notice:  fputcsv(): delimiter must be a single character in /work/app/sample.tsv on line 4

問題のコード

sample.php
<?php

$handle = fopen('sample.tsv', 'w');
fputcsv($handle, ['apple', 'banana', 'lemon'], '\t');
fclose($handle);

問題点

シングルクォーテーションで囲んでいたのが問題でした。

sample.php
fputcsv($handle, ['apple', 'banana', 'lemon'], "\t");

'\t'"\t" と変更するとエラーメッセージがなくなりました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0