From: Operating system: PHP version: 5.2.14 Package: Scripting Engine problem Bug Type: Bug Bug description:list() uses overwritten variable
Description: ------------ When a parameter to list() and the variable assigned to it are the same (that means list(...,$a)=$a;), list() uses the new value of the variable (once it's been overwritten) and reads the remaining parameters from this new value. This is surprising and undocumented behaviour. It would be better if list() kept assigning values from the originally assigned array. The problem exists in PHP 5.3.2-2 too. This is not important, just surprising. Array variables usually get named distinctly from other variables, so the conflict doesn't surface often. Test script: --------------- $n=array("b","#123"); list($b,$n)=$n; // Currently equivalent to "$n=$n[1]; $b=$n[0];" echo $b; Expected result: ---------------- b Actual result: -------------- # -- Edit bug report at http://bugs.php.net/bug.php?id=53332&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=53332&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=53332&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=53332&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=53332&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=53332&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=53332&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=53332&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=53332&r=needscript Try newer version: http://bugs.php.net/fix.php?id=53332&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=53332&r=support Expected behavior: http://bugs.php.net/fix.php?id=53332&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=53332&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=53332&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=53332&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53332&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=53332&r=dst IIS Stability: http://bugs.php.net/fix.php?id=53332&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=53332&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=53332&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=53332&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=53332&r=mysqlcfg