PHP approach to python's magic __getattr__()
问题 I was wondering if there was some way in PHP to duplicate some of the magic of Python attribute/key access. I use a Mongo ORM class written by Steve Lacey called Minimongo in which he utilizes the __getattr__ and __getitem__ to reroute key and attribute flavored access and preserve the 'document-oriented' nature of Mongo. val = doc.foo and val = doc['foo'] become equivalent. I was wondering if there is a similar interface in PHP that would allow the changing of how object access is handled