Object reference

From: Date: Thu, 21 Mar 2002 10:19:38 +0000
Subject: Object reference
Groups: php.general 
Request: Send a blank email to php-general+get-89482@lists.php.net to get a copy of this message
I can't understand why this works like it does. class MyObj { var $Name; function MyObj($Name) { $this->Name = $Name; } } $a = new MyObj('MyObjName'); $b = $a; $b->Name = 'NoName'; echo $a->Name; Last line will output 'MyObjName' instead of 'NoName' (like I was expecting) I'd expect $a and $b to behave like reference pointers (change in $b is reflected in $a and vice versa) instead of copiing $a to $b (beiing a Delphi programmer this is as natural to me as the Sun raising in east and setting in west :-) So, is there a way to do this; pointers or something maybe? Lucijan

« previous php.general (#89482) next »