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]; }