views:

40

answers:

1

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

class Bootstrap extends MyBootstrap
{

}

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

+1  A: 

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.

Piotr Pankowski
Isn't there something more consistent?
Rodrigo Alves
Nothing I would be aware of. Only other way is to call each method manually but I guess this is not what you are looking for.
Piotr Pankowski