note 11380 modified in Classes and Objects by jmcastagnetto

From: Date: Thu, 01 Mar 2001 23:05:17 +0000
Subject: note 11380 modified in Classes and Objects by jmcastagnetto
Groups: php.notes 
Request: Send a blank email to php-notes+get-11747@lists.php.net to get a copy of this message
[Editor's note: the nothe author is using a very strange and non standard syntax to access method results. Not even hardcore OOP languages use this strange contstructs] 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/classes-and-objects.php

« previous php.notes (#11747) next »