Posted by howachen on 05/14/06 18:40
hi,
in http://hk.php.net/manual/en/language.oop5.patterns.php, it mentions
the use of "Singleton"function. e.g.
//*********************
public static function singleton()
{
if (!isset(self::$instance)) {
$c = __CLASS__;
self::$instance = new $c;
}
return self::$instance;
}
//*********************
if this instance use a lot of memory, would it be better if i use
reference?
e.g.
//*********************
public static function &singleton()
{
if (!isset(self::$instance)) {
$c = __CLASS__;
self::$instance = new $c;
}
return self::$instance;
}
//*********************
any comments? or the php compiler can auto optimize for me?
Navigation:
[Reply to this message]
|