class DZ {
public $file_DZ;
public function __construct($file) {
$this->$file = $file;
$file_DZ = fopen($file, 'a');
}
public function WriteFile($text) {
fwrite($this->$file_DZ, $text . PHP_EOL);
}
public function __destruct() {
fclose($this->$file_DZ);
}
}
error_reporting(-1);
require_once 'DZ.php';
$file = new DZ('DZ.txt');
$file->WriteFile('Строка 1');