- var_dump: documentation ( source)
<?php
class Foo {
public $secret = 'I actually prefer coding with Go';
public function getClosure() : closure
{
return function() {
return $this->secret;
};
}
public function dontLeakMyStuff()
{
return create_function('', 'return $this->secret;');
}
}
$foo = new Foo();
$closure = $foo->getClosure();
var_dump($closure());
$function = $foo->dontLeakMyStuff();
var_dump($function());