PHP 5 supports the overloading of the __get() __set() methods, which are responsible for being called when a particular class variable is requested but doesn't explicitally exist.

<?php
    
class anotherfoo {

        private 
$testvar = array ('test'=> 10);

        function 
__get($varname) {

            return 
$this->testvar[$name];

        }

        function 
__set($varname$value) {

            
$this->testvar[$name] = $value;
        }

    }

    
$varinst = new anotherfoo();
    
$varinst->test++;
    echo 
"The value of 'test' is {$varinst->test}";
?>