Hi,
here is in my opinion, what you can do:
class Base
{
private $foo;
private function __construct()
{}
public function getFoo()
{
return $this->foo;
}
public function setFoo( $foo )
{
$this->foo = $foo;
}
}
class Singleton extends Base
{
public function __construct()
{}
private function __clone()
{}
public static function getInstance()
{
static $instance = null;
if (!isset($instance))
$instance = new self();
$instance->setFoo( 'singleton' );
return $instance;
}
}
$bar = Singleton::getInstance();
echo $bar->getFoo(); // "Singleton"
Regards
Carlos
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php