我需要能够调用一个函数,但函数名存储在一个变量中,这可能吗?例如:

function foo ()
{
  //code here
}

function bar ()
{
  //code here
}

$functionName = \"foo\";
// i need to call the function  d on what is $functionName

如何实现呢:

 

实现方法:

function foo($msg) {
    echo $msg.\"<br />\";
}
$var1 = \"foo\";
$var1(\"testing 1,2,3\");
收藏 打印