
- You are not logged in. | Login
March 16, 2007 3:50 pm
- shadow122
- Member


Appealing to classes!
Tell me, please, how to appeal from script to class:
class Csvwriter
{
private $file;
private $delimiter;
private $array;
private $handle;
public function __construct($file, $array, $delimiter=";")
{
$this->file = $file;
$this->array = $array;
$this->delimiter = $delimiter;
$this->FileOpen();
}
public function __destruct()
{
$this->FileClose();
}
public function GetCsv()
{
$this->SetCsv();
}
private function IsWritable()
{
if(is_writable($this->file))
return true;
else
return false;
}
private function SetCsv()
{
if($this->IsWritable())
{
$content = "";
foreach($this->array as $ar)
{
$content .= implode($this->delimiter, $ar);
$content .= "\r\n";
}
if (fwrite($this->handle, $content) === FALSE)
exit;
}
}
private function FileOpen()
{
$this->handle=fopen($this->file, 'w+');
}
private function FileClose()
{
if($this->handle)
@fclose($this->handle);
}
}
$array = array(array('1','1','1'), array('2','2','2'), array('3','3','3'));
$dd = new Csvwriter('test.txt',$array);
$dd->GetCsv();
?>
March 16, 2007 3:51 pm
March 16, 2007 3:56 pm
- shadow122
- Member


Re: Appealing to classes!
Thanks for information but there is nothing concerning my problem:
class CsvReader
{
private $file;
private $delimiter;
What is private???
Could you give some example of appealing to class?
March 16, 2007 4:00 pm
- Mr.SMart
- Member


Re: Appealing to classes!
shadow122, can you read? The link and search on forum contain all the information you need 


