PHP pass function name as param then call the function


I need to pass a function as a parameter to another function and then call the passed function from within the function…This is probably easier for me to explain in code..I basically want to do something like this:

function ($functionToBeCalled)

Is there a way to do that.. I am using PHP 4.3.9


Best Solution

I think you are looking for call_user_func.

An example from the PHP Manual:

function barber($type) {
    echo "You wanted a $type haircut, no problem";
call_user_func('barber', "mushroom");
call_user_func('barber', "shave");