cat_name .'/'. date('Y-m-d').'.txt'; $structure = $_SERVER['DOCUMENT_ROOT'].'/api/logs'.'/'.$this->cat_name; if ( !is_dir($structure) and !mkdir($structure, 0777, true)) { die('Не удалось создать директории...'); } //var_dump('sdfsdf'); $file = $structure . '/'.date('Y-m-d').'.txt'; $current = ''; if ( is_file($file)) { $current = file_get_contents($file); } $current .= $message . "\n"; $res = file_put_contents($file, $current); // сохраняем в файл } public function log($message,$cat) { // запись ошибки в логфайл $cat = explode('\\',$cat); $this->cat_name = array_pop($cat); $this->saveToFile($message); } }