php - Concat a variable to a function name -


how can concatenate variable containing string function name? tried methods, none worked me.

$mode = 'remove';  friend.$mode.($mode);  function friendremove() {  } 

you can use call_user_func http://lv1.php.net/call_user_func this:

$mode = 'remove'; call_user_func('friend'.$mode, $p1, $p2, ...);  function friendremove($p1, $p2, ...) {} 

also there call_user_func_array function useful http://lv1.php.net/call_user_func_array


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -