following this article on the Observer Pattern:
http://mesoimpact.com/articles/errorHandling.html

i in the following class,i use the getinstance to instantiate other classes,however,i can not seem to pass any parameters to the instantiated classes.

class Singleton{
    function &getInstance ($class, $name = NULL){
        static $registry = array();
        $_instanceName = is_null($name) ? $name : $class;
        if ( !isset($registry[$class][$_instanceName]) || !is_object($registry[$class][$_instanceName]) ) {
            $registry[$class][$_instanceName] =& new $class;
        }
        return $registry[$class][$_instanceName];
    } # end method     

}

for example,i want to use the getinstance to have an instance of the class ERRORS,at the same time pass some parameters to the ERRORS class' constructor.

any ideas?

    Write a Reply...