I store all variables settings for some project in a class named Ini. Variables are stored in group of arrays. For example, I have several arrays – one for ‘database’ related stuff, another for ‘debug’ related stuff and so on.
So to access for example some settings in my code i would type:
$ini = new Ini();
echo $ini->database['user'];
echo $ini->debug['mode'];
I don’t like my way of doing this. I would like to access variables stored inside Ini class like this:
$ini->database->user;
or
$ini->debug->mode;
The problem is that i am referencing non existing object inside another object. And i found no way to catch such call and return values stored in original Ini object (via PHP __get() method)
Would appreciate some help finding solution to my problem.
Just create objects of the standard class:
as an optional choice, you can take your existing arrays and cast them to objects and access with the same syntax: