ID: 28050 Updated by: [EMAIL PROTECTED] Reported By: mmertinkat at justseven dot de -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: Windows XP PHP Version: 4.3.6 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 See bug #20993. Previous Comments: ------------------------------------------------------------------------ [2004-06-09 02:05:34] spy at spy dot zp dot ua Indeed, it's very very strange behavior... If even we consider that initial submission is not a bug, then this example - is a bug. <?php $data['settings']['account']['password'] = 'not secret'; $account =& $data['settings']['account']; $mysettings = $data['settings']; var_dump($mysettings); // here we can see that mysettings recognized as reference unset($account); // MAGIC unset var_dump($mysettings); // and now (!) it is not a reference $mysettings['account']['password'] = 'very secret'; var_dump($data); ?> ------------------------------------------------------------------------ [2004-05-06 09:09:12] bart at mediawave dot nl Simplified version that has the same (wrong?) behavior: <?php $data['settings']['account']['password'] = 'not secret'; print_r($data); $account =& $data['settings']['account']; $mysettings = $data['settings']; $mysettings['account']['password'] = 'very secret'; print_r($data); ?> Pretty weird indeed. ------------------------------------------------------------------------ [2004-04-30 03:49:04] mmertinkat at justseven dot de damn ... this is _definately_ a bug! the problem is, that $mysettings = $data['settings']; $mysettings['account']['password'] = 'very secret'; should _NOT_ change anything within $data (because $data['settings'] is copied to $mysettings), but it does! ------------------------------------------------------------------------ [2004-04-29 23:00:00] [EMAIL PROTECTED] Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Thank you for your interest in PHP. Please read the manual about references (what they are, what they are not, when to use, when not to use..) ------------------------------------------------------------------------ [2004-04-18 17:38:04] mmertinkat at justseven dot de Description: ------------ Just look at the code; it is reproducible with PHP 4.3.4, 4.3.5 and 4.3.6 on Windows and Linux. Reproduce code: --------------- <? $data = NULL; $data['settings']['account']['firstname'] = 'Johnny'; $data['settings']['account']['lastname'] = 'Walker'; $data['settings']['account']['username'] = 'johnny'; $data['settings']['account']['password'] = 'not secret'; /**********************************************/ print_r($data); $settings = $data['settings']; $account = &$settings['account']; // we're now going to change the account password and therefore // use the $account array as a "shortcut" (reference) to $settings['account'] $account['password'] = 'secret'; // write any changes into the data array $data['settings'] = $settings; /******************/ // the following two lines will (mistakenly?) touch the $data array ... $mysettings = $data['settings']; $mysettings['account']['password'] = 'very secret'; // ... whereas the next two lines don't change anything (as it should be) $myaccount = $data['settings']['account']; $myaccount['password'] = 'very very secret'; print_r($data); ?> Expected result: ---------------- Array ( [settings] => Array ( [account] => Array ( [firstname] => Johnny [lastname] => Walker [username] => johnny [password] => not secret ) ) ) Array ( [settings] => Array ( [account] => Array ( [firstname] => Johnny [lastname] => Walker [username] => johnny [password] => secret ) ) ) Actual result: -------------- Array ( [settings] => Array ( [account] => Array ( [firstname] => Johnny [lastname] => Walker [username] => johnny [password] => not secret ) ) ) Array ( [settings] => Array ( [account] => Array ( [firstname] => Johnny [lastname] => Walker [username] => johnny [password] => very secret ) ) ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28050&edit=1