Page 1 of 1

[SOLVED] PHP 4 Object question

Posted: Wed Mar 02, 2005 8:54 am
by Jean-Yves
Hi,

If I do the following

Code: Select all

$objectA = new MyObject;

$objectB = $objectA;
I have two separate objects. Changing the values of attributes in A for example does not change the attributes in B.

What I would like is two references to the object created in the first line. How do I go about doing that in PHP4 syntax?

Many thanks.

Posted: Wed Mar 02, 2005 9:10 am
by smpdawg
Use this to get the reference.

Code: Select all

$objectB = & $objectA;

Posted: Wed Mar 02, 2005 9:40 am
by Jean-Yves
THanks very much, works perfectly.

:D

Posted: Wed Mar 02, 2005 9:51 am
by smpdawg
That's what I am here for. :)