类中属性定义闭包 (Closure) 为什么不执行?
calss A {
protected $closure;
protected closure()
{
return $this->closure;
}
public function set(Closure $callback)
{
$this->closure = $callback;
return $this;
}
public function get()
{
return $this->closure();
}
}
$a = new A();
$a->set(function() {
return 'closure';
};);
var_dump($a->get());
推荐文章: