note 77393 added to language.oop5.patterns
| From: | ConcernedCoder at osu1 dot php dot net | Date: | Tue, 28 Aug 2007 05:27:14 +0000 |
| Subject: | note 77393 added to language.oop5.patterns | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129844@lists.php.net to get a copy of this message | ||
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;
}
}
?>
----
Server IP: 64.71.164.2
Probable Submitter: 69.200.231.140
----
Manual Page -- http://www.php.net/manual/en/language.oop5.patterns.php
Edit -- https://master.php.net/note/edit/77393
Del: integrated -- https://master.php.net/note/delete/77393/integrated
Del: useless -- https://master.php.net/note/delete/77393/useless
Del: bad code -- https://master.php.net/note/delete/77393/bad+code
Del: spam -- https://master.php.net/note/delete/77393/spam
Del: non-english -- https://master.php.net/note/delete/77393/non-english
Del: in docs -- https://master.php.net/note/delete/77393/in+docs
Del: other reasons-- https://master.php.net/note/delete/77393
Reject -- https://master.php.net/note/reject/77393
Search -- https://master.php.net/manage/user-notes.php