RE: [PHP] Object reference

From: Date: Thu, 21 Mar 2002 10:36:24 +0000
Subject: RE: [PHP] Object reference
Groups: php.general 
Request: Send a blank email to php-general+get-89483@lists.php.net to get a copy of this message
Hi, Use & to reference one variable to another! $b =& $a; Lars -----Original Message----- From: Lucijan [mailto:lucijan@altavista.net] Sent: 21 March 2002 10:20 To: php-general@lists.php.net Subject: [PHP] Object reference 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#89483) next »