note 91885 deleted from functions.anonymous by thiago
| From: | thiago@php.net | Date: | Tue, 30 Jun 2009 19:01:32 +0000 |
| Subject: | note 91885 deleted from functions.anonymous by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-157714@lists.php.net to get a copy of this message | ||
Note Submitter: nate at example dot com
----
Am I the only one who finds it ridiculous that you have to explicitly import variables into a
closure (using the "use" syntax)? A closure by definition should inherit the scope of the
parent where the closure is defined
If php played by the rules of standard programming practice, the following example would work as-is,
without having to add a "use ($var)" clause. Flawed implementation, like so many things in
the world of php.
<?
$var = 'hello';
$lamba = function () { var_dump($var); };
$lambda();
?>