- var_dump: documentation ( source)
<?php
class Foo {
function bar($x) {
$that = $this;
$powerOfThree = function($x) use ($that) {
return $that->square($x) * $x;
};
return $powerOfThree($x);
}
public function square($x) {
return $x * $x;
}
}
$foo = new Foo();
var_dump($foo->bar(2));