« Back to the index
\patterns\Singleton example
";
$S = \patterns\Singleton::getInstance('myS');
// This is totally equivalent to:
$S = myS::getInstance();
print "A result with our singleton: ".$S->getData() . "
";
print "Let's try to duplicate our singleton and get an error:
";
$S2 = new myS();
// this can make an error too:
$S2 = clone $S;
?>
« Back to the index