#20993 [NEW]: Element value changes without asking

From: Date: Fri, 13 Dec 2002 18:00:37 +0000
Subject: #20993 [NEW]: Element value changes without asking
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-27637@lists.php.net to get a copy of this message
From: henrik.gebauer@web.de Operating system: Windows 2002 PHP version: 4.3.0RC3 PHP Bug Type: Variables related Bug description: Element value changes without asking I create an array an then a reference to an element of that array. Then the array is passed to a function (by value!) which changes the value of the element. After that, the global array has also another value. I would expect this behaviour if I passed the array by reference but I did not. <?php $array = array(1); $reference =& $array[0]; echo $array[0], '<br>'; theFunction($array); echo $array[0], '<br>'; function theFunction($array) { $array[0] = 2; } ?> -- Edit bug report at http://bugs.php.net/?id=20993&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=20993&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=20993&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=20993&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=20993&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=20993&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=20993&r=support Expected behavior: http://bugs.php.net/fix.php?id=20993&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=20993&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=20993&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=20993&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20993&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=20993&r=dst IIS Stability: http://bugs.php.net/fix.php?id=20993&r=isapi

« previous php.bugs (#27637) next »