How can I call functions on PHP using eval()? is it possible? I wanna do something like this
<?php
$function1 = 'echo';
$function2 = 'implode';
$arr = array('arg1', 'arg2');
eval("$function1 ($function2(', ', $arr));");
?>
Or call other functions with multiple params? Is eval() what I'm looking for? Many thanks!
You don't need to eval anything:
$function1 = 'print';
$function2 = 'implode';
$arr = array('arg1', 'arg2');
$function1($function2(', ', $arr));
In fact, you can even use variable, variables:
$foo = 'print';
$bar = 'foo';
$$bar('hello');