#35022 [NEW]: key() malfunctions on references

From: Date: Sun, 30 Oct 2005 11:36:33 +0000
Subject: #35022 [NEW]: key() malfunctions on references
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-87209@lists.php.net to get a copy of this message
From: stas at zend dot com Operating system: * PHP version: 5CVS-2005-10-30 (CVS) PHP Bug Type: Scripting Engine problem Bug description: key() malfunctions on references Description: ------------ Consider the code below: it does not produce correct results on 4.4, 5.1 head, but worked in some 5.0 versions due to the fact that key() is defined as by-ref function in 5.0. Reproduce code: --------------- <? $state = array("one" => 1, "two" => 2, "three" => 3); function foo( &$state ) { $contentDict = end( $state ); for ( $contentDict = end( $state ); $contentDict !== false; $contentDict = prev( $state ) ) { echo key($state)."\n"; } } foo($state); ?> Expected result: ---------------- three two one Actual result: -------------- one one one -- Edit bug report at http://bugs.php.net/?id=35022&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=35022&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=35022&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=35022&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=35022&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=35022&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=35022&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=35022&r=needscript Try newer version: http://bugs.php.net/fix.php?id=35022&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=35022&r=support Expected behavior: http://bugs.php.net/fix.php?id=35022&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=35022&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=35022&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=35022&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35022&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=35022&r=dst IIS Stability: http://bugs.php.net/fix.php?id=35022&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=35022&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=35022&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=35022&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=35022&r=mysqlcfg

« previous php.bugs (#87209) next »