2010-05-10 28 views

回答

1

嘗試這樣的自舉類中:

$methods = get_class_methods ('MyBootstrap'); 
foreach ($methods AS $method) { 
    if (str_pos ($method, '_init') !== false) { 
     call_user_func (array ($this, $method)); 
    } 
} 

get_class_methods - 返回類的方法名。然後查找'_init'等方法並運行它們。

+0

是不是有更一致的東西? – 2010-05-17 14:06:44

+0

沒有我會意識到的。只有其他方法是手動調用每種方法,但我想這不是你想要的。 – 2010-05-17 14:56:40

相關問題