Edit report at https://bugs.php.net/bug.php?id=52165&edit=1
ID: 52165 Updated by: fel...@php.net Reported by: TerenceHardwicke at safetymail dot info Summary: a closure fails to modify a variable in the outer scope -Status: Open +Status: Closed Type: Bug Package: Scripting Engine problem Operating System: Debian Linux 5 PHP Version: 5.3.2 -Assigned To: +Assigned To: felipe Block user comment: N Private report: N New Comment: This bug has been fixed in SVN. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. For Windows: http://windows.php.net/snapshots/ Thank you for the report, and for helping us make PHP better. It has already been fixed. Thanks. Previous Comments: ------------------------------------------------------------------------ [2010-06-23 22:32:27] TerenceHardwicke at safetymail dot info Description: ------------ my configure line was: ./configure --prefix /usr/local/php/5.3.2 --disable-libxml --disable-dom --disable-simplexml --disable-xml --disable-xmlreader --disable-xmlwriter --without-pear Test script: --------------- <?php $total = 0; f(function ($x) use (&$total) { $total += $x; }, function () use ($total) {}); var_dump($total); $total = 0; f(function ($x) use (&$total) { $total += $x; }); var_dump($total); function f($g) { foreach (range(1, 10) as $x) $g($x); } Expected result: ---------------- The following 2 lines should be output by the script: int(55) int(55) Actual result: -------------- The script outputs the following 2 lines: int(0) int(55) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=52165&edit=1