note 85213 rejected from language.oop5.references by thiago

From: Date: Wed, 20 Aug 2008 19:10:13 +0000
Subject: note 85213 rejected from language.oop5.references by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-143685@lists.php.net to get a copy of this message
Note Submitter: couchand at gmail dot com ---- The above doesn't really make this clear, but the following: <?php class A { public $foo = 1; } $a = new A; $b = $a; // $a and $b are copies of the same identifier // ($a) = ($b) = <id> $c = &$a; // $c is a reference to $a $c->foo = 2; $a = NULL; // the object persists after the demise of $a echo "a: ".$a->foo."\n"; echo "b: ".$b->foo."\n"; echo "c: ".$c->foo."\n"; ?> Outputs: a: b: 2 c:

« previous php.notes (#143685) next »