对于common,get_instance_of的静态问题

浏览:1760 发布日期:2014/05/11 分类:求助交流 关键字: 静态类,get_instance_of
function get_instance_of($name, $method='', $args=array()) {
static $_instance = array();
$identify = empty($args) ? $name . $method : $name . $method . to_guid_string($args);
if (!isset($_instance[$identify])) {
if (class_exists($name)) {
$o = new $name();
if (method_exists($o, $method)) {
if (!empty($args)) {
$_instance[$identify] = call_user_func_array(array(&$o, $method), $args);
} else {
$_instance[$identify] = $o->$method();
}
}
else
$_instance[$identify] = $o;
}
else
halt(L('_CLASS_NOT_EXIST_') . ':' . $name);
}
return $_instance[$identify];
}
为什么对于静态属性 static $_instance = array();,引用的时候没有加入self::?我自己测试没有加入self关键字的话,是读取不到类的静态属性的,而是新增一个$_instance属性,属于对象的,求解。
最佳答案
评论( 相关
后面还有条评论,点击查看>>