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.
精彩评论