hi,
in http://hk.php.net/manual/en/language.oop5.patterns.php, it mentions
the use of "Singleton"func tion. 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?
in http://hk.php.net/manual/en/language.oop5.patterns.php, it mentions
the use of "Singleton"func tion. 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?
Comment