What I’d like ti achieve is that when I call $obj->CAT[15];
the $obj would check if the property CAT exists if not, get the value on the fly
public function __get($var){
if($var == "CAT") return $this->cats->get_cat($cat_id);
}
so my question is… how to get array’s value 15 from my example? to pass it to my get_cat method?
Have
__getreturn an instance ofArrayAccesswhich will delegate toget_catin itsoffsetGetmethod.Something like this: