| | #1 |
| HyperActive Warrior War Room Member Join Date: 2006 Location: Ireland
Posts: 294
Thanks: 5
Thanked 34 Times in 25 Posts
|
Is it possible to do the following? $result = function1()->function2()->function3(); It's very handy to write code like this, easier to read and shorter too! The only alternative I see is this: $first = function1(); $second = $first->function2(); $result = $second->function3(); This is assuming function1 returns an object containing function2 and function2 returns an object containing function3. So the question remains.. is this possible: $result = function1()->function2()->function3(); Thanks! Sean |
| http://javadocs.com - Javadocs
| |
| |
| | #2 |
| Spartan Warrior War Room Member Join Date: 2008
Posts: 869
Thanks: 130
Thanked 149 Times in 75 Posts
|
in PHP 5 yes.
|
| | |
| |
| | #3 |
| HyperActive Warrior War Room Member Join Date: 2006 Location: Ireland
Posts: 294
Thanks: 5
Thanked 34 Times in 25 Posts
|
Example: In Java this is possible: int count = new Family().getEldestChild().getNumberOfToes(); In PHP I would assume it would be something like this: $count = new Family()->getEldestChild()->getNumberOfToes(); but I'm having no luck with it. Google searches didn't help either. Any ideas if this is possible? Sean |
| http://javadocs.com - Javadocs
| |
| |
| | #4 |
| HyperActive Warrior War Room Member Join Date: 2006 Location: Ireland
Posts: 294
Thanks: 5
Thanked 34 Times in 25 Posts
|
Thanks Mark, yes you're right, I needed to upgrade my version of PHP, I was using an old version of WAMP. It's working now. Beautiful! Sean |
| http://javadocs.com - Javadocs
| |
| |
|
| Bookmarks |
| Tags |
| call, function, object, php, returned |
| |