|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits              [2001-08-22 12:20 UTC] olli at ukgamer dot net
  [2001-08-22 16:19 UTC] jeroen@php.net
 | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 01:00:01 2025 UTC | 
<? Class ChildClass { var $value; function ChildClass($value){ $this->value = $value; } } Class ParentClass { var $children; function ParentClass(){ $this->children = array(); } function AddChild($value){ $child = &new ChildClass($value); array_push($this->children, &$child); return $child; } } $p1 = &new ParentClass(); $c1 = &$p1->AddChild('set in constructor'); $c1->value = 'set elsewhere'; echo "the reference to the object created in AddBand and stored in the parentclass' array is different to that returned by the AddBand function<br>"; echo $p1->children[0]->value."<br>"; echo $c1->value; ?> "return" is returning a copy of the object created in parentclass->AddChild instead of a reference. "return &$object" is flagged as invalid by the php interpreter. thanks a lot olli holliday