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

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -