magic methods

Proxy pattern with PHP 5

PHP from version 5 on provides reasonable object support. Well the language is not really object-oriented, but hey, it's a scripting language!

Recently I had the chance to implement the proxy pattern (one of my favourite design patterns) in PHP. My goal was to make object relations more dynamical. Lets start from a simple assumption of two kinds of objects:

class Parent {
 var $ID;
 var $Child;
}
 
class Child {
 var $ID;
 var $Parent;
}

As you'll notice, both classes reference each other. Parent points at Child and Child points to Parent.