How to call a function from a string stored in a variable?

Lizard picture Lizard · Jun 17, 2009 · Viewed 284.4k times · Source

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