Thanks Johan, I tried your suggestion but got: Fatal error: Call to a member function on a non-object in /usr/local/apache/php/testchain.php on line 47
I think you might have me on the right track though :) I tried this as well: ${$foo->get("bar")}->getBaz(); but got the same error. Terry ----- Original Message ----- From: "Johan Ohlin" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, November 11, 2002 11:45 AM Subject: Re: [PHP] method chaining > If I have understood correctly what you want to do then this will do fine... > > $foo->${$foo->get("bar")}->getBaz(); > > / Johan > > ----- Original Message ----- > From: "Terry McBride" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Monday, November 11, 2002 4:53 PM > Subject: [PHP] method chaining > > > > Hello, > > > > I have a question about php and OO. I want to chain methods together > having > > them performed on the results of the following method. Meaning something > > like $foo->get("bar")->getBaz(). > > > > I get the following error from the script bellow. > > Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ',' or > ';' > > in /usr/local/apache/php/testchain.php on line 47 > > > > Anybody know why I can't do this? Anyway to make it it one statement > > instead of $tmp = $foo->get("bar"); $tmp->getBaz(); -- lame --? > > Is their a config setting or something? > > > > Thanks in advance, > > Terry > > > > <?php > > > > class Foo > > { > > var $vector = array(); > > function Foo() > > {} > > > > function put($name, $value) > > { > > $this->vector[$name] = $value; > > return $this->vector[$name]; > > } > > > > function get($name) > > { > > return $this->vector[$name]; > > } > > > > } > > > > class Bar > > { > > var $baz = ""; > > > > function Bar() {} > > > > function setBaz($value) > > { > > $this->baz = $value; > > return $this->baz; > > } > > function getBaz() > > { > > return $this->baz; > > } > > } > > > > $bar = new Bar(); > > $bar->setBaz("test succeeded"); > > > > $foo = new Foo(); > > $foo->put("bar", $bar); > > > > echo $foo->get("bar")->getBaz(), "<br>"; > > > > ?> > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php