note 11380 modified in language.oop by aidan
| From: | aidan@php.net | Date: | Sat, 03 Jul 2004 14:57:39 +0000 |
| Subject: | note 11380 modified in language.oop by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72468@lists.php.net to get a copy of this message | ||
[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();
?>
--was--
[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:
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://php.net/manual/en/language.oop.php