|
|
|
|
|
by fooyc
4497 days ago
|
|
AFAIK, `use` were required because PHP has variable-variables: <?php
$x = "b";
$b = 42;
echo $$x; // equivalent to echo $b;
// Here the compiler can't determine all the variables
// used in the function.
// Has a result, there were two choices:
// - capture the whole environment
// - capture explicitly named variables
function () {
return $$x;
}
Hopefully, nobody uses variable-variables these days, however this is the reason behind the introduction of `use` for closures. |
|