|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-02-15 00:29 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 14:00:01 2025 UTC |
Description: ------------ Part of this report is related with BUG#24807. In the following code, I would like to get and set an object property in the way similar to that in Java, C# and Delphi, e.g., "$a->Child->Name='xxx'" and "echo $a->Child->Name". However, the PHP parser would not allow the first usage. Another question is about array property. Within current PHP5 release, I can't see a way to define an object property that is of array type and supports access to individual array element. These two questions may not be considered as bugs, however, to my belief they are very fundamental to object properties. Reproduce code: --------------- class Input { private $_name='abc'; private $_child; function __get($name) { if($name=='Name') return $this->_name; else if($name=='Child') { if(!isset($this->_child)) $this->_child=new Input; return $this->_child; } } function __set($name,$value) { if($name=='Name') $this->_name=$value; } } $a=new Input; $a->Child->Name='cde'; echo $a->Child->Name; Expected result: ---------------- cde Actual result: -------------- Fatal error: Cannot access undefined property for object with overloaded property access ...