|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: hawcue at yahoo dot com
New email:
PHP Version: OS:


 [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: Mon May 20 12:01:33 2024 UTC