Syntax B doesnt seem to work exactly because as you say "it doesn't directly 
access the 'bars' variable...";


$reference_to_bar = $this->GetBar($id) ;

it seems that a copy of the bar object is being created, which is a new 
object.  This new bar object is not related to the bar object which is a 
part of the $bars array property of the foo object.

When you set the marklar property to the new value ...

$reference_to_bar->SetMarklar($value) ;

the value is changed for the new copy of the bar object you have just 
created.  Because this value is assigned to the new object it doesn't appear 
when you print the contents of foo.  This is illustrated by the lines i've 
added below.

Maybe after setting the new property value you could reassigned this object 
to the $bars array of object foo.

I'm no expert but it's always fun to play with code...

Hope this helps in some way,


But this syntax doesn't: and this
would be prefered, as it doesn't directly
access the 'bars' variable...

$reference_to_bar = $this->GetBar($id) ;
echo $reference_to_bar->marklar;
$reference_to_bar->SetMarklar($value) ;
echo $reference_to_bar->marklar;

Chat with friends online, try MSN Messenger: http://messenger.msn.com

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to