note 77393 deleted from language.oop5.patterns by felipe
| From: | felipe@php.net | Date: | Sat, 15 Dec 2007 01:52:07 +0000 |
| Subject: | note 77393 deleted from language.oop5.patterns by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133512@lists.php.net to get a copy of this message | ||
Note Submitter: Concerned Coder
----
In the example given below by alexandre at ONLY-HAM-NOT-SPAM dot gaigalas dot net, I'm pretty
sure that would always assign $i to a new instance.
I'd imagine he means something like this:
<?php
class foo
{
static private $i;
private function __construct()
{
echo "I'm alive";
}
static public function singleton()
{
return (isset(self::$i) || (($n = __CLASS__) && (self::$i = new $n)) ? self::$i :
NULL;
}
}
?>