PHP pass function name as param then call the function?

I think you are looking for call_user_func.

An example from the PHP Manual:

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

Leave a Comment