开发者

How do I init every parent method before init?

开发者 https://www.devze.com 2022-12-29 13:56 出处:网络
I have a custom bootstrap class and I\'m extending it. class Bootstrap ex开发者_如何转开发tends MyBootstrap

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

精彩评论

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