From: adam at trachtenberg dot com Operating system: * PHP version: 5CVS-2004-04-08 (dev) PHP Bug Type: Zend Engine 2 problem Bug description: foreach() with references broken when iterating only over value
Description: ------------ In PHP 5, foreach() allows you to iterate over values by reference. This does not work when you do foreach($array as $value) instead of foreach($array as $key => $value). I believe this patch fixes the problem, but someone should *really* double check it. :) http://www.trachtenberg.com/patches/ foreach_by_reference.txt Reproduce code: --------------- php -r '$array = array(); foreach($array as $value) {)' Expected result: ---------------- Nothing. Actual result: -------------- PHP Fatal error: Key element cannot be a reference in Command line code on line 1 -- Edit bug report at http://bugs.php.net/?id=27923&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27923&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27923&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=27923&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=27923&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=27923&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=27923&r=needscript Try newer version: http://bugs.php.net/fix.php?id=27923&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=27923&r=support Expected behavior: http://bugs.php.net/fix.php?id=27923&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=27923&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=27923&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=27923&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27923&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=27923&r=dst IIS Stability: http://bugs.php.net/fix.php?id=27923&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=27923&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=27923&r=float