|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-05-02 11:20 UTC] andrey@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 15:00:01 2025 UTC |
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