您也可以访问私有数据
<?php
class Value {
private $value;
public function __construct($value) {
$this->value = $value;
}
}
$foo = new Value('Foo');
$bar = new Value('Bar');
$closure = function () { var_dump($this->value); };
$closure->call($foo);
$closure->call($bar);
?>
输出
string(3) "Foo"
string(3) "Bar"