php - How to define function name using variable? -
how define function name (in php) using variable, this?
$a='blabla'; function {$a}() {.......}
or that?
the way know give fixed name function use eval, not suggest.
more likely, want stuff function in variable, , call that.
try this:
$a = function() { echo 'this called anonymous function.'; } $a();
edit: if want accessible other files, use global variable:
$globals['variable_name'] = 'my_func_123'; ${$globals['variable_name']} = function() { echo 'this called anonymous function.'; }; // executing my_func_123() ${$globals['variable_name']}();
Comments
Post a Comment