예제 #1
0
파일: zotop.php 프로젝트: dalinhuang/zotop
 public static function instance($classname, $method = '', $args = array())
 {
     static $instances = array();
     $id = empty($args) ? strtolower($classname . $method) : strtolower($classname . $method . zotop::guid($args));
     if (!isset($instances[$id])) {
         if (class_exists($classname)) {
             $instance = new $classname();
             if (method_exists($instance, $method)) {
                 $instances[$id] = call_user_func_array(array(&$instance, $method), $args);
             } else {
                 $instances[$id] = $instance;
             }
         } else {
             msg::error($classname . ' not found!');
         }
     }
     return $instances[$id];
 }