Advertisement
Guest User

stdClass

a guest
May 17th, 2011
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.34 KB | None | 0 0
  1. class standardClass extends stdClass
  2. {
  3.  
  4.     public function __get( $index )
  5.     {
  6.    
  7.         if( !isset( $this->$index ) || !$this->$index instanceof stdClass )
  8.         {
  9.             $this->$index = new standardClass();
  10.             return $this->$index;
  11.         }
  12.         else
  13.         {
  14.             return $this->$index;
  15.         }
  16.        
  17.     }
  18.    
  19. }
  20.  
  21. $x = new standardClass();
  22. $x->y->z = 123;
  23. print_r( $x );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement