Just playing around with overloading....

Here's a container class into which objects can be lazy loaded via a factory pattern. I thought it was kind of neat, anyway....

PHP Code:
<?php


class Container {


    public function 
__construct()
    {
        echo 
'I am empty :-(<br />';
    }
    
    
    private static function 
containedFactory($className$args=null)
    {
        
$fullClassName 'Contained_'.ucwords($className);
        
        if (!
is_array($args)) {
            
$ret = new $fullClassName;
        } else {
            
$ret call_user_func_array(
                            array(new 
ReflectionClass($fullClassName), 'newInstance'), $args
                        
);
           }
           
           echo 
'Container now holds a new instance of '.$fullClassName.'<br />';
           return 
$ret;
    }
    
    
    
    public function 
__get($className)
    {
        if (!isset(
$this->$className)) {

            
$this->$className self::containedFactory($className);
        }

        return 
$this->$className;
    }
    
    
    
    public function 
__call($className$constructArgs)
    {
        
$this->$className self::containedFactory($className$constructArgs);
    }
    
    
}



class 
Contained_A {
    
    
    public function 
sayHi()
    {
        echo 
'Hi!<br />';
    }    
    

}


class 
Contained_B {


    public function 
__construct($color='blue')
    {

        echo 
'<span style="color: '.$color.';">Hello from Contained_B!</span><br />';
    
    }
    
    
    public function 
sayBye()
    {
        echo 
'Bye.<br />';
    }    
    

}





$container = new Container;

$container->a->sayHi(); // creates a new instance of Contained_A, and calls its sayHi method


$container->b('green'); // new instance of Contained_B with a constructor argument
$container->b->sayBye(); // call Contained_B method

$container->a(); // creates a new instance of Contained_A
$container->a->sayHi(); // call Contained_A method

$container->b(); // new instance of Contained_B

?>