From:             [EMAIL PROTECTED]
Operating system: Linux, Windows
PHP version:      4.2.3
PHP Bug Type:     Scripting Engine problem
Bug description:  Getting reference instead of copy of object

Normally this code should print "0", 
however, when uncommenting a single empty method call, 
it outputs "1".
It seems like a copy suddenly becomes a reference.

<?php

$a1 = new A();
//$a1->c->f();  // uncomment this to expose error.
$a2 = $a1;
$a2->c->x = 1;
echo $a1->c->x;

class C {
    var $x = 0;
    function f() {}
}

class A {
    var $c;
    function A() { $this->c = new C(); }
}

?>

Thanks. 
Anahoret Team.
-- 
Edit bug report at http://bugs.php.net/?id=19738&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=19738&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=19738&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=19738&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=19738&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=19738&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=19738&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=19738&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=19738&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=19738&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=19738&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=19738&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=19738&r=dst

Reply via email to