ID: 27627 Updated by: [EMAIL PROTECTED] Reported By: jparneodo at yahoo dot fr -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: Red Hat 9.0 PHP Version: 4.3.5RC3 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php When you try to access a non-existant array element you effectively create it, hence the NULL entries in the array. Previous Comments: ------------------------------------------------------------------------ [2004-03-17 10:29:18] jparneodo at yahoo dot fr 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 this bug report at http://bugs.php.net/?id=27627&edit=1
