I think he was making an assumption about PHP based on how other
languages work. Everyone in the class is using Python or Java. He
is letting me use PHP, which hasn't been done before in this class.
Thanks for the tip on objects, I'll keep that in mind.
-Aaron
On Feb 26, 2007, at 10:16 AM, Brian Dailey wrote:
If your professor was referring to PHP, it's possible he could have
been referring to objects, not arrays. Objects are copied by
reference, so if you do this:
$Item = new Item;
$Item2 = $Item;
$Item2->setProductId('12');
print $Item->getProductId();
Your output will be '12'. If you want to copy an object in PHP 5
you'll need to use 'clone.'
Aaron Fischer wrote:
Indeed it does. Sorry! I was led to believe (by my cs professor)
that the default behavior when copying an array is that the copied
array is not a new instance but is tied by pointers to the old
array, so changes to one would change both of them.
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php