ID: 33061
Updated by: [EMAIL PROTECTED]
Reported By: online at natweiss dot com
-Status: Open
+Status: Assigned
Bug Type: Class/Object related
-Operating System: Linux
+Operating System: *
-PHP Version: 5.*, 4.*
+PHP Version: 5.* (2005-06-19)
-Assigned To:
+Assigned To: dmitry
New Comment:
ATTENTION: This does NOT happen with PHP_4_4 !!
Simplified example:
<?php
class something {
public $val = 0;
}
function pass_by_value($value) {
$value->val = 1;
}
$object = new something;
var_dump($object);
pass_by_value($object);
var_dump($object);
?>
Expected result:
----------------
int(0)
int(0)
Actual result:
--------------
int(0)
int(1)
Previous Comments:
------------------------------------------------------------------------
[2005-06-07 04:13:52] online at natweiss dot com
Okay. I turned off turck mmcache and the results are the same. Here is
the output:
php -v
------
PHP 4.3.12-dev (cli) (built: Jun 3 2005 22:16:42)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend
output of reproduce code
------------------------
member->val should be empty!
something Object
(
[member] => something Object
(
[val] => 1
)
)
------------------------------------------------------------------------
[2005-05-19 02:39:30] online at natweiss dot com
Description:
------------
See reproduce code.
php.ini is stock / no changes.
Reproduce code:
---------------
<?php
// a class that does nothing
class something{
function nothing(){
}
}
// a pass-by-value function that modifies a member's member
function pass_by_value($value){
$value->member->val = 1;
}
// create a something with a member something
$object = new something;
$object->member = new something;
// call nothing, then call pass_by_value and print results
$object->member->nothing();
echo "member->val should be empty!\n";
pass_by_value($object);
print_r($object);
?>
Expected result:
----------------
$object->member should be empty
Actual result:
--------------
$object->member->val == 1
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33061&edit=1