#48380 [NEW]: Class is passed as reference in array?

From: Date: Mon, 25 May 2009 08:27:01 +0000
Subject: #48380 [NEW]: Class is passed as reference in array?
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-137698@lists.php.net to get a copy of this message
From: catalint at gmail dot com Operating system: Linux PHP version: 5.2.9 PHP Bug Type: Scripting Engine problem Bug description: Class is passed as reference in array? Description: ------------ Class is passed as reference in array ? Reproduce code: --------------- $a= new stdClass(); $test=array(); for ($i=0;$i<5;$i++){ $a->i=$i; $test[]=$a; } print_r($test); Expected result: ---------------- Array ( [0] => stdClass Object ( [i] => 0 ) [1] => stdClass Object ( [i] => 1 ) [2] => stdClass Object ( [i] => 2 ) [3] => stdClass Object ( [i] => 3 ) [4] => stdClass Object ( [i] => 4 ) ) Actual result: -------------- Array ( [0] => stdClass Object ( [i] => 4 ) [1] => stdClass Object ( [i] => 4 ) [2] => stdClass Object ( [i] => 4 ) [3] => stdClass Object ( [i] => 4 ) [4] => stdClass Object ( [i] => 4 ) ) -- Edit bug report at http://bugs.php.net/?id=48380&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48380&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48380&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48380&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48380&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48380&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48380&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48380&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48380&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48380&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48380&r=support Expected behavior: http://bugs.php.net/fix.php?id=48380&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48380&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48380&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48380&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48380&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48380&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48380&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48380&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48380&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48380&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48380&r=mysqlcfg

« previous php.bugs (#137698) next »