ID: 44677 Updated by: [EMAIL PROTECTED] Reported By: kudung at gmx dot net -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: Debian 4 PHP Version: 5.2.5 New Comment:
RTFM: http://www.php.net/manual/en/language.oop5.basic.php "When assigning an already created instance of a class to a new variable, the new variable will access the same instance as the object that was assigned. This behaviour is the same when passing instances to a function. A copy of an already created object can be made by cloning it." Previous Comments: ------------------------------------------------------------------------ [2008-04-09 10:01:55] kudung at gmx dot net Description: ------------ Hi, just discovered that an parameter wich passed to an function as an non reference of type object is handeld as an reference, but if i pass a parameter of type array to the function it is handled as a copie as it should be. Reproduce code: --------------- class foob { function testbar( $das ) { unset( $das->ding ); } } function testbar( $das ) { unset( $das->ding ); } $ers = new stdClass(); $ers->ding = '323'; testbar($ers); var_dump( $ers ); $ers2 = new stdClass(); $ers2->ding = '323'; $foob = new foob(); $foob->testbar($ers2); var_dump( $ers2 ); Expected result: ---------------- Expected that properties still exists: object(stdClass)#1 (1) { ["ding"]=> string(3) "323" } object(stdClass)#2 (1) { ["ding"]=> string(3) "323" } Actual result: -------------- Output: object(stdClass)#1 (0) { } object(stdClass)#2 (0) { } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44677&edit=1