$this->$fn是一个函数名,
return $this->$fn($command)返回的是$fn($commmand)方法的返回值。例如
class test
{
function one($command)
{
return $command+1;
} function two($command)
{
return $command+2;
} function GetAuth ($command)
{
$this->cfgUserAuth = "one";
$fn = $this->cfgUserAuth;
return $this->$fn($command);
}}$obj = new Test();
echo $obj->GetAuth(3);//将输出:4
return $this->$fn($command)返回的是$fn($commmand)方法的返回值。例如
class test
{
function one($command)
{
return $command+1;
} function two($command)
{
return $command+2;
} function GetAuth ($command)
{
$this->cfgUserAuth = "one";
$fn = $this->cfgUserAuth;
return $this->$fn($command);
}}$obj = new Test();
echo $obj->GetAuth(3);//将输出:4
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货