$someValue = "sample external data";
$simpleClosure = function() use($someValue) {
return "Test accessing external value inside closure ".$someValue;
};
echo $simpleClosure();
class SimpleClass {
private $privateData = 2;
}
$simpleClosure = function() {
return $this->privateData;
};
$resultClosure = Closure::bind($simpleClosure, new SimpleClass(), 'SimpleClass');
echo $resultClosure();