$this关键字和紧凑的功能
在某些上下文中,我们可以使用语法来引用对象属性。为什么不行?有没有办法解决这个问题?array($this, 'variable')
compact(array($this, 'variable'))
class someclass {
$result = 'something';
public function output() {
compact($this->result); // $this is a OOP keyword and I don't know how to use it inside a compact() brackets
}
}
我目前只找到了一个解决方案:
$result = $this->result;
compact('result');
但这是丑陋的。