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

What can cause "Required Package 'IndyCore' not found" when compiling a Delphi 2010 project? -

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