CodeIgniter - 从变量调用方法
问题描述:
让我们保持简单。 我们有这样的:CodeIgniter - 从变量调用方法
public function db($method)
{
$this->$method.'()';
}
我'肯定这是非常自我解释。基本上,我想我所有的方法被称为波谷这种方法“DB”,但这是错误:
Message: Undefined property: site::$db
埃姆...
我想我可以写全手工制作的可能的情况,但真的有必要吗?
答
你有没有试过call_user_func($function);
或者
$this->$function()
或者
$this->{$function}()
不幸的是,但没有这些工作。 – SmOg3R