andmefail); if(count($m)!=2){die("Failinimel pole yhte laiendit");} if($m[1]=="txt"){ return parent::loeTooted(); } $abi=json_decode(file_get_contents($this->andmefail)); foreach($abi as $rida){ array_push($this->tooted, array($rida->nimetus, $rida->hind, 0)); } } } $korv1=new Ostukorv6("esimene", "tooted2.txt"); echo $korv1->toodeteLoetelu(); //$korv1->hoiatus="ohtlik"; //echo $korv1->hoiatus; echo "Kokku: ".$korv1->toodeteSumma(); $korv2=new OstukorvJSON("teine", "tooted6.json"); echo $korv2->toodeteLoetelu(); echo "Kokku: ".$korv2->toodeteSumma();