Hello I'm having some trouble creating an array that should hold all the instances of my class. For example I'd like that everytime I instantiate an object from my main class to automatically put that object in an empty array created previously in the class.
class Meniu_de_baza{
private $nume;
private $descriere_ro;
private $descriere_en;
private $pret;
private $array_obiecte[];
function __construct($n,$d_ro,$d_en,$p){
$this->nume = $n;
$this->descriere_ro = $d_ro;
$this->descriere_en = $d_en;
$this->pret = $p;
$this-array_obiecte = $this-
}
function getPret(){
return $this->pret;
}
function setPret($set_pret){
if(is_numeric($set_pret)){
$this->pret = $set_pret;
}else{
echo "Pretul este invalid!";
}
}
function detalii_mancare(){
echo "Ati comandat {$this->nume} ce contine: <br />" . "{$this->descriere_ro} <br />";
}
function nota_plata(){
echo "Nota Plata: <br />{$this->nume} 1 portie <br /> TOTAL: {$this->pret} RON";
}
}
The code is attached as an image due to an issue I've occured trying to put it in a code block. Thanks in advance. Any advice is appreciated.