21,887
社区成员
发帖
与我相关
我的任务
分享
/**
+----------------------------------------------------------
* 取得对象实例 支持调用类的静态方法
+----------------------------------------------------------
* @param string $class 对象类名
* @param string $method 类的静态方法名
+----------------------------------------------------------
* @return object
+----------------------------------------------------------
*/
static public function instance($class,$method='') {
$identify = $class.$method;
if(!isset(self::$_instance[$identify])) { //这一行的self::不是太明白怎么回事
if(class_exists($class)){ //这个是判断如果类存在?
$o = new $class();
if(!empty($method) && method_exists($o,$method))
self::$_instance[$identify] = call_user_func_array(array(&$o, $method)); //这一行怎么解释?
else
self::$_instance[$identify] = $o; //这一行怎么解释?
}
else
halt(L('_CLASS_NOT_EXIST_').':'.$class); //halt从来没见过这东西……
}
return self::$_instance[$identify];
}