开发者

How do I init every parent method before init?

I have a custom bootstrap class and I'm extending it.

class Bootstrap ex开发者_如何转开发tends MyBootstrap
{

}

MyBootstrap.php class have some _init methods. I need it to load all MyBootstrap methods first. How to?


Try something like this inside the Bootstrap class:

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

get_class_methods - returns the class methods' names. Then look for methods like '_init' and run them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜