I need to be able to call a function, but the function name is stored in a variable, is this possible? e.g:
function foo ()
{
//code here
}
function bar ()
{
//code here
}
$functionName = "foo";
// I need to call the function based on what is $functionName
$functionName()orcall_user_func($functionName)If you need to provide parameters stored in another variable (in the form of array), use array unpacking operator:
To dynamically create an object and call its method use
or to call a static method