All pastes #336817 Raw Edit

Someone

public text v1 · immutable
·published 2007-02-02 08:56 UTC
rendered paste body
class test {
    
    var $val = 0;
    
    function &getInstance(){
        static $instance = array();
		if (!$instance) {
			$instance[0] =& new test;
		}
		return $instance[0];
    }
    
    function get(){
        $_this =& test::getInstance();
        return $_this->val;
    }
    
    function set($value){
        $_this =& test::getInstance();
        $_this->val = $value;
    }
}

$class = new test();
$class->set(4);


echo test::get();

test::set(10);

$class = new test();
echo $class->get();