0
我正在做一個插件系統,目前我不得不使用call_user_func_array
。這很慢並且使用內存。_callstatic裏面靜態類的調用不起作用
我的功能是工作,看起來像這樣:
public static function __callStatic($method, $args)
{
$plugins = self::_checkEventCache($method);
if(count($plugins)) :
foreach($plugins as $p):
$tmp = call_user_func_array(array(self::$_installedPlugins[$p], $method), array(&$args));
endforeach;
endif;
self::$_current_event = $method;
}
我的問題是我怎麼能叫這直接或使這個速度呢?我永遠不會知道後面會附加多少個參數。
任何解決方案來擺脫call_user_func_array
?
$tmp =
對此也不起作用。早些時候 - 當我沒有使用靜態時,它返回一個值。我使用的舊代碼是這樣的:
$tmp = $this->_installedPlugins[$p]->{$method}($args);
if($tmp !== NULL){
$this->_event_result[$method] = $tmp;
}
當我使用靜態類時,我需要得到相同的結果。
任何想法?
謝謝。就是我所搜索的。在on表達式中我也遇到了這個問題。所以,問題解決了。 –