Is it possible to do the following? $result = function1()->function2()->function3();
Call function on returned Object in PHP
4
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
$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
- Mark Brian
- Sean Kelly
- Sean Kelly
Next Topics on Trending Feed
-
4