[SOLVED] PHP 4 Object question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

[SOLVED] PHP 4 Object question

Post 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.
Last edited by Jean-Yves on Wed Mar 02, 2005 9:43 am, edited 1 time in total.
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

Use this to get the reference.

Code: Select all

$objectB = & $objectA;
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Post by Jean-Yves »

THanks very much, works perfectly.

:D
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

That's what I am here for. :)
Post Reply