#27627 [NEW]: function & fct() create entry in array if key does not exist

From: Date: Wed, 17 Mar 2004 15:29:18 +0000
Subject: #27627 [NEW]: function & fct() create entry in array if key does not exist
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-56591@lists.php.net to get a copy of this message
From: jparneodo at yahoo dot fr Operating system: Red Hat 9.0 PHP version: 4.3.5RC3 PHP Bug Type: Scripting Engine problem Bug description: function & fct() create entry in array if key does not exist Description: ------------ Returning by reference in a function or method modify the array if the key asked does not exist Reproduce code: --------------- $a=array('x'=>1,'y'=>2); function & getZ(){ global $a; return $a['z']; } function & getT(&$a){ return $a['t']; } function & get4(&$a){ return $a[4]; } getZ(); print_r($a); getT($a); print_r($a); get4($a); print_r($a); Expected result: ---------------- Array ( [x] => 1 [y] => 2 ) Array ( [x] => 1 [y] => 2 ) Array ( [x] => 1 [y] => 2 ) Actual result: -------------- Array ( [x] => 1 [y] => 2 [z] => // NULL ) Array ( [x] => 1 [y] => 2 [z] => // NULL [t] => // NULL ) Array ( [x] => 1 [y] => 2 [z] => // NULL [t] => // NULL [4] => // NULL ) -- Edit bug report at http://bugs.php.net/?id=27627&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27627&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27627&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=27627&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=27627&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=27627&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=27627&r=needscript Try newer version: http://bugs.php.net/fix.php?id=27627&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=27627&r=support Expected behavior: http://bugs.php.net/fix.php?id=27627&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=27627&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=27627&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=27627&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27627&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=27627&r=dst IIS Stability: http://bugs.php.net/fix.php?id=27627&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=27627&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=27627&r=float

« previous php.bugs (#56591) next »