note 76597 deleted from language.oop5.patterns by felipe
| From: | felipe@php.net | Date: | Sat, 15 Dec 2007 01:38:56 +0000 |
| Subject: | note 76597 deleted from language.oop5.patterns by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133508@lists.php.net to get a copy of this message | ||
Note Submitter: alexandre at ONLY-HAM-NOT-SPAM dot gaigalas dot net
----
A minimalistic singleton implementation I create for my new framework
<?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;
}
}
?>