note 11380 added to Classes and Objects
| From: | sgarner at expio dot co dot nz | Date: | Sun, 18 Feb 2001 23:15:35 +0000 |
| Subject: | note 11380 added to Classes and Objects | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-11226@lists.php.net to get a copy of this message | ||
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();
:-(
http://www.php.net/manual/en/language.oop.php