failinimi=$failinimi; $this->loe(); } function tyhjenda(){$this->andmed=array();} function lisa(Andmeliides $obj){ array_push($this->andmed, $obj); $this->salvesta(); } private function salvesta(){ $abi=array(); foreach($this->andmed as $teade){ $obj=new Stdclass(); $obj->pealkiri=$teade->kysiPealkiri(); $obj->sisu=$teade->kysiSisu(); array_push($abi, $obj); } file_put_contents($this->failinimi, json_encode($abi)); } private function loe(){ if(file_exists($this->failinimi)){ $abi=json_decode(file_get_contents($this->failinimi)); $this->andmed=array(); foreach($abi as $teade){ array_push($this->andmed, new Andmeobjekt($teade->pealkiri, $teade->sisu)); } } } function kysiAndmeLiidesed(){ return $this->andmed; } //Koosta lihtne demofail paari kirje lisamise ja vaatamisega }