faqts : Computers : Programming : Languages : PHP : kms : Classes

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

22 of 26 people (85%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

Can I string together object references, eg: $foo->bar()->try() ?

Aug 27th, 2003 16:12
Peter Theill, Nathan Wallace,


No. This will be available in PHP 5.

If you do it in two steps it will work, i.e.:

  $temp = $foo->bar();
  $temp->try();

Are you using simple "getter" functions you might consider doing it like:

  $obj->foo_->bar();

Where "obj" points to an object having a "foo_" object variable having a
"bar()" function. It works but might not be exactly what you're looking
for :-/