note 11380 deleted from language.oop by danbrown
| From: | danbrown@php.net | Date: | Sat, 07 Nov 2009 19:04:20 +0000 |
| Subject: | note 11380 deleted from language.oop by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162575@lists.php.net to get a copy of this message | ||
Note Submitter: sgarner at expio dot co dot nz
----
[Editor's note: Remember tha PHP is not a hard core OOP language, and even the ones that are do
not always support the unusual vector/array references applied to results from methods.]
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:
<?php
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();
?>