Re: Is it correct?

From: Date: Sun, 20 Aug 2000 20:07:33 +0000
Subject: Re: Is it correct?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-12666@lists.php.net to get a copy of this message
Darvin Andrioli writes: > Hello, > > I've defined the following class: > > class a { > var $myvar_a; > function a() { > $this->myvar_a=1; > } > } > > class b { > var $myvar_b; > function b() { > $this->myvar_b=new a(); > } > } > > then if I run the following code... > > $myClass=new b(); > echo("myvar_a: $myClass->myvar_b->myvar_a <br>"); > echo("myvar_a: " . $myClass->myvar_b->myvar_a . " <br>"); > > ... I obtain: > > myvar_a: Object->myvar_a > myvar_a: 1 > > I'm expecting to get "myvar_a=1" from both statement. Is it correct? > > Bye > > Darvin When inside a string and involving more than one level of objects, you'll need to delimit it with {..}:: echo("myvar_a: {$myClass->myvar_b->myvar_a} <br>"); echo("myvar_a: " . $myClass->myvar_b->myvar_a . " <br>"); Cheers, Torben -- +----------------------------------------------------------------+ |Torben Wilson <torben@php.net> Netmill iTech| |http://www.coastnet.com/~torben http://www.netmill.fi| |Ph: 1 250 383-9735 torben@netmill.fi| +----------------------------------------------------------------+

« previous php.general (#12666) next »