Function/method syntax limitations

From: Date: Tue, 20 Feb 2001 23:23:59 +0000
Subject: Function/method syntax limitations
Groups: php.general 
Request: Send a blank email to php-general+get-40851@lists.php.net to get a copy of this message
I posted this to the Manual notes the other day, but I thought I'd repost it here for discussion. :) It seems there is no way to access the return value of a method (or any function) inline, without assigning it to a variable. For example: class Test { function blah () { return array(1,2,3); } function childTest () { return new Test; } } $test = new Test; // This does not work: $foo = $test->blah()[0]; // Instead have to do: $temp = $test->blah(); $foo = $temp[0]; // Similarly for objects, cannot do: $foo = $test->childTest()->blah(); // Instead have to do: $temp = $test->childTest(); $foo = $temp->blah(); :-( Regards Simon Garner

« previous php.general (#40851) next »