With this extension you can use closures without use
statement
$x = 100;
$foo = function() {
return $x;
};
echo $foo(), PHP_EOL;
- if local variable is created by passing by reference
$foo = function () {
// workaround: $matches = [];
preg_match('/^test$/', 'test', $matches); // Undefined variable $matches
return $matches[0] ?? '';
};
echo $foo(), PHP_EOL;
extract
,eval
and other ways to implicitly create variable
$foo = function() {
// workaround: $x = 0;
eval('$x = 100;'); Undefined variable $x
return $x;
};
echo $foo(), PHP_EOL;
phpize
./configure
make
make install
make test