Skip to content

Instantly share code, notes, and snippets.

@shmurakami
Last active March 18, 2020 08:39
Show Gist options
  • Save shmurakami/4b7df838b83907bd36d48316f6bcc701 to your computer and use it in GitHub Desktop.
Save shmurakami/4b7df838b83907bd36d48316f6bcc701 to your computer and use it in GitHub Desktop.
<?php
class Sample
{
private $fp;
public function __construct($local_filepath)
{
$this->fp = fopen($local_filepath, 'w');
if ($this->fp === false) {
throw new \Exception(__METHOD__ . " filepath: $local_filepath への書き込みに失敗しました");
}
}
public function send(array $row)
{
return fputcsv($this->fp, $row);
}
public function close()
{
fclose($this->fp);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment