#25898 [Opn->WFx]: array returning mechanism from objects?

From: Date: Mon, 02 May 2005 09:20:38 +0000
Subject: #25898 [Opn->WFx]: array returning mechanism from objects?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-78503@lists.php.net to get a copy of this message
ID: 25898 Updated by: andrey@php.net Reported By: sven at leon dot uia dot mx -Status: Open +Status: Wont fix Bug Type: Feature/Change Request Operating System: All (redhat 90) PHP Version: 5.0.0b1 (beta1) New Comment: AFAIK this is "Won't fix". Brought already on the internals ML but no interest from Z/A. Previous Comments: ------------------------------------------------------------------------ [2003-10-17 13:21:39] sven at leon dot uia dot mx Description: ------------ Im not sure if it is a bug or not. with an object inside an object, this is possible: echo $test->testobject()->color; with and array inside an object, this is NOT possible: echo $test->testarray()["color"]; In other words, when an object returns an array, I can not directly access it. This will work: $temparray=$test->testarray(); echo $temparray["color"]; Reproduce code: --------------- <?php class c_testobject{ function __construct(){ $this->color="red"; } } class c_test{ private $testobject; private $testarray=array("color" => "red"); function testobject(){ $testobject=new c_testobject; return $testobject; } function testarray(){ return $testarray; } } $test=new c_test(); echo $test->testobject()->color; echo $test->testarray()["color"]; ?> Expected result: ---------------- redred Actual result: -------------- Parse error: parse error, expecting ','' or ';'' in /var/www/html/php-easy/test.php on line 19 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25898&edit=1

« previous php.bugs (#78503) next »