Possible Duplicate:
Calling closure assigned to object property directly
如果是这样的话:
class test{
function one(){
$this->two()->func(); //Since $test is returned, why can I not call func()?
}
function two(){
$test = (object) array();
$test->func = function(){
echo Does this work? ;
};
return $test;
}
}
$new = new test;
$new->one(); //Expecting Does this work?
因此,我的问题是,当我从职能一中讲职能二时,职能二是把印数作为回报,该变量具有随附的结局。 为什么我不能把这称作一种链条的方法?
Edit I just remembered that this can also be done by using $this->func->__invoke() for anyone that needs that.