1class SimpleClass {
2 private $privateData = 2;
3}
4
5$simpleClosure = function() {
6 return $this->privateData;
7};
8
9$resultClosure = Closure::bind($simpleClosure, new SimpleClass(), 'SimpleClass');
10
11echo $resultClosure();
12
1$someValue = "sample external data";
2$simpleClosure = function() use($someValue) {
3 return "Test accessing external value inside closure ".$someValue;
4};
5echo $simpleClosure();
6