__get( ) specifies what to do if an unknown property is read from within your script : __get « Class « PHP






__get( ) specifies what to do if an unknown property is read from within your script

 
<?
    class Dog {
            public $Name;
            public $DogTag;
  
            public function __get($var) {
                    print "Attempted to retrieve $var and failed...\n";
            }
    }

    $poppy = new Dog;
    print $poppy->Age;
?>
  
  








Related examples in the same category

1.Intercepting Property Access with __get() and __set() (PHP 5 Only)
2.Enforcing property access using magic accessor methods