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();