At this point, I respectfully disagree. To say it's not supported is one thing but to say it's better or more efficient convincingly requires more. Tell me why :)
Who's repeating/repassing? I'm under the impression it would be faster for the interpreter if the statement were chained, also a copy (memory) of the object would be not be required. Oops, I mis-spoke, actually a copy would be required due to the the referencing conventions - perhaps this is not useful anyway given what I really want is... $tmp =& $foo->get("bar"); // note the & $tmp->alterBarSomeWay(); // $tmp->getBaz(); No way to do that in one line. I think the reference conventions are odd. I can pass a variable to a function not knowing it may be referenced and altered (unless I check the signature), but I have to know that what I'm receiving from a function is a reference in order to grab it properly!? I wish I knew why these decisions went the way the did. Terry ----- Original Message ----- From: "Maxim Maletsky" <[EMAIL PROTECTED]> To: "Terry McBride" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Monday, November 11, 2002 11:20 AM Subject: Re: [PHP] method chaining > work around: > > $obj = $foo->get("bar"); > $obj->getBaz(); > > it is a better way as you don't have to re-repeat the function code and > re-pass the oblect. > > -- > Maxim Maletsky > [EMAIL PROTECTED] > > > > "Terry McBride" <[EMAIL PROTECTED]> wrote... : > > > 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