- var_dump: documentation ( source)
<?php
class ClosureTester {
public $string = 'default';
public function foo() {
return $this->string;
}
public function someMethod() {
$this->string = 'a';
$self = $this;
$closure = function() use (&$self) {
return $self->foo();
};
return $closure();
}
}
$c = new ClosureTester();
var_dump($c->someMethod());