is (( $objectA->fx('foo') )->fxBar() )[1]; possible ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aaaaaaaa
Forum Newbie
Posts: 13
Joined: Wed Aug 19, 2009 8:43 am

is (( $objectA->fx('foo') )->fxBar() )[1]; possible ?

Post by aaaaaaaa »

Hey everyone,

The problem is quite simple :)

I have that kind of functions, with objects from differents classes

$object2=$objectA->fx('foo');
$array=$object2->fxBar();
echo $array[1];

and I would like to do that :

echo (( $objectA->fx('foo') )->fxBar() )[1];

I know that it works with other languages like java, by catings objects
User avatar
arjan.top
Forum Contributor
Posts: 305
Joined: Sun Oct 14, 2007 4:36 am
Location: Hoče, Slovenia

Re: is (( $objectA->fx('foo') )->fxBar() )[1]; possible ?

Post by arjan.top »

you can chain method calls, but ->foo()[0] wont work
aaaaaaaa
Forum Newbie
Posts: 13
Joined: Wed Aug 19, 2009 8:43 am

Re: is (( $objectA->fx('foo') )->fxBar() )[1]; possible ?

Post by aaaaaaaa »

thanks for the answer. Even if method chaining is really not what I want to do, your post informed me about PHP syntax.
Post Reply