This issue with the same variable being used repeatedly in closures, sometimes by reference, sometimes by value was a known bug in versions of PHP up to 5.3.5. PHP 5.3.6 attempted to fix the issue, but introduced a new bug in doing so. The problem was finally resolved in PHP 5.3.7
Can't edit an array value in closure
Frage
Hey, I'm not quite sure if it is a bug or just a feature change:
$a = array(array(0));
array_walk(
$a,
function (&$e) {
array_filter(array(), function() use ($e) {});
$e[] = 1;
}
);
print_r($a[0]);
in PHP 5.5.3-1ubuntu2.3 returns
Array
(
[0] => 0
[1] => 1
)
and in PHP 5.3.3-7+squeeze19
Array
(
[0] => 0
)
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow