|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29458 Dereferencing, __get and array property
Submitted: 2004-07-30 16:03 UTC Modified: 2005-02-15 00:29 UTC
Avg. Score:4.8 ± 0.4
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:4 (100.0%)
From: hawcue at yahoo dot com Assigned:
Status: Closed Package: Class/Object related
PHP Version: 5.0.0 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
29 - 21 = ?
Subscribe to this entry?

 [2004-07-30 16:03 UTC] hawcue at yahoo dot com
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) {
			return $this->_name;
		else if($name=='Child') {
				$this->_child=new Input;
			return $this->_child;
	function __set($name,$value) {
$a=new Input;
echo $a->Child->Name;

Expected result:

Actual result:
Fatal error: Cannot access undefined property for object with overloaded property access ...


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-15 00:29 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 24 06:01:38 2024 UTC