#44933 [Bgs]: Assignment is done as if by reference

From: Date: Wed, 07 May 2008 10:29:14 +0000
Subject: #44933 [Bgs]: Assignment is done as if by reference
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-124791@lists.php.net to get a copy of this message
ID: 44933 Updated by: scottmac@php.net Reported By: remon at menpmedia dot nl Status: Bogus Bug Type: Class/Object related Operating System: Fedora Core 4 PHP Version: 5.2.6 New Comment: You probably have zend.ze1_compatibility_mode enabled which causes the behavior of php4 but it has bugs and is generally unused. Previous Comments: ------------------------------------------------------------------------ [2008-05-07 09:39:02] remon at menpmedia dot nl [root@batai ~]# php <?php print phpversion(); echo "\n"; $one = new stdClass(); $one->variable = 'hello'; $two = $one; $two->variable = 'goodbye'; var_dump($one); ?> 5.2.4 object(stdClass)#3 (1) { ["variable"]=> string(5) "hello" } [root@batai ~]# ------------------------------------------------------------------------ [2008-05-07 09:36:16] remon at menpmedia dot nl ????? Now I am really confused. Im running Fedora Core 8 / x64, php 5.2.4, and i have the, by your statement, incorrect result I understand this has changed and I understand the implication (review all our code which at this point amounts to several million lines of code :( ) I also understand that i need to 'clone' an object. Shame that PHP4 doesn't understand this keyword and throws an error; so much for writing universal code. Thank you for all your comments and views. ------------------------------------------------------------------------ [2008-05-07 09:31:27] derick@php.net I am running this on 64bit linux, and on 32bit as well. I get the same correct result. ------------------------------------------------------------------------ [2008-05-07 09:28:04] remon at menpmedia dot nl Thank you scottmac, this helps a bit. Should I consider PHP5/x64/linux bugged then for NOT reflecting this behavioural change ? ------------------------------------------------------------------------ [2008-05-07 09:23:45] scottmac@php.net The behavior changed between php4 and php5. When you pass around an object it uses the same instance. The clone keyword will let you duplicate an object. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/44933 -- Edit this bug report at http://bugs.php.net/?id=44933&edit=1

« previous php.bugs (#124791) next »