|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-05-07 08:40 UTC] remon at menpmedia dot nl
Description:
------------
Problem:
Changing property of a copy of an object results in the changing of the original object as if by reference.
Correct output is from 5.2.4
Incorrect output is from 5.2.6
This problem does NOT occur when using an array!
configure command (taken from phpinfo())
'./configure' '--with-apxs' '--with-curl=/usr/local/lib' '--with-gd' '--enable-gd-native-ttf' '--with-ttf' '--with-gettext' '--with-jpeg-dir=/usr/local/lib' '--with-freetype-dir=/usr/local/lib' '--with-kerberos' '--with-openssl' '--with-mcrypt' '--with-mhash' '--with-mysql=/usr' '--with-mysqli=/usr/bin/mysql_config' '--with-pear' '--with-png-dir=/usr/local/lib' '--with-zlib' '--with-zlib-dir=/usr/local/lib' '--enable-zip' '--with-iconv=/usr/local' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-mbstring'
other info;
sorry, unavailable; we do not have root access to the server in question. Cannot get a diff between the ini and ini-dist, cannot do a trace.
Reproduce code:
---------------
<?php
$one = new stdClass();
$one->variable = "hello";
$two = $one;
$two->variable = "goodbye";
var_dump($one);
?>
Expected result:
----------------
object(stdClass)#3 (1) {
["variable"]=>
string(5) "hello"
}
Actual result:
--------------
object(stdClass)#1 (1) {
["variable"]=>
string(7) "goodbye"
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Dec 09 03:00:01 2025 UTC |
[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 ~]#