Skip to content

Instantly share code, notes, and snippets.

@valdiney
Created April 23, 2016 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valdiney/d88b0b27c7b167764ae94f69deca3cc7 to your computer and use it in GitHub Desktop.
Save valdiney/d88b0b27c7b167764ae94f69deca3cc7 to your computer and use it in GitHub Desktop.
Exporting data to the txt file
<?php
/*
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @author Valdiney França <valdiney.2@hotmail.com>
* @version 0.1
* With this class you can pass data into the text file of simple way.
*/
class ExportToTxt
{
protected $path;
protected $file;
# Receive the path of the archive text
public function set_path($path)
{
$this->path = $path;
}
# Receive the file, do not need pass the extension of the file
public function set_file($file)
{
$help = "{$this->path}/{$file}.txt";
$this->file = fopen($help, 'w');
}
# This method is used to write the data in the archive text
public function write_in_file($archives)
{
fwrite($this->file, $archives);
}
# You shold use this method to close de connection with the archive
public function close()
{
fclose($this->file);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment