=& 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
olog-hai
Forum Commoner
Posts: 34
Joined: Thu May 31, 2007 8:47 am
Location: Québec city, QC, Canada

=& Question

Post by olog-hai »

Hey,

In PHP 5 we have no longer have to put "&" after = to use reference right ? cause by defaut php 5 do not make copy of object right ?

If I do this

Code: Select all

$obj = new MyClass();
the $obj will content the reference of the object

why this code do a copy of the object instead of copy the reference ?

Code: Select all

$a = array();

$a["test"] = new MyClass();
$a["test"] is a copy of MyClass and not reference, why i have to specify =& to get the reference ?

thanks.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Works fine for me..

Care to post where it is actually not working?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What version of PHP 5 are you seeing this on? Where's the proof it's a copy?
User avatar
olog-hai
Forum Commoner
Posts: 34
Joined: Thu May 31, 2007 8:47 am
Location: Québec city, QC, Canada

Post by olog-hai »

8O

sorry guys it works perfectly.

you can delete this post
Post Reply