[SOLVED] overloading classes with array accessor
Posted: Tue Aug 04, 2009 8:43 pm
Hi!
I've been using Doctrine, and one of the features that I like (simply because it is pretty) is the ability to access member variables as if the object were an array. For example, all of the following lines are equivalent to each other:
I know how to use __call to make the first three lines happen, but I've no idea how to emulate the fourth. I poured through a lot of the Doctrine code, but there is way too much of it for me to figure out this particular aspect.
Does anybody know how to do it, or even have any ideas? Let me know if I've been at all unclear.
Thank you!
Matt
I've been using Doctrine, and one of the features that I like (simply because it is pretty) is the ability to access member variables as if the object were an array. For example, all of the following lines are equivalent to each other:
Code: Select all
echo $user->username;
echo $user->get('username');
echo $user->getUsername;
echo $user['username'];Does anybody know how to do it, or even have any ideas? Let me know if I've been at all unclear.
Thank you!
Matt