note 46680 added to language.oop5.reflection
| From: | russ dot collier at gmail dot com | Date: | Wed, 20 Oct 2004 03:40:46 +0000 |
| Subject: | note 46680 added to language.oop5.reflection | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-78802@lists.php.net to get a copy of this message | ||
Actually, aside from my inconsistent order of keywords in the 2 factory methods ;-) the
Triangle::getInstance() method has 1 glaring flaw: it never actually sets the Triangle::$instance
property. The correct way to implement a Singleton this way would be to replace
Triangle::getInstance() with this:
<?php
static public function getInstance()
{
if ( null == self::$instance )
{
self::$instance = new self;
return self::$instance;
}
return self::$instance;
}
?>
----
Manual Page -- http://www.php.net/manual/en/language.oop5.reflection.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46680
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46680&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46680&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46680&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46680&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46680&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46680&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46680&report=yes
Search -- http://master.php.net/manage/user-notes.php