Re[2]: [PHP] object passing by reference

From: Date: Wed, 27 Nov 2002 14:55:56 +0000
Subject: Re[2]: [PHP] object passing by reference
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-126288@lists.php.net to get a copy of this message
Hi This should do it: class parentClass { var $x; var $child; function parentClass($_x, &$_child) { //<<<<<<<<<<<<< $this->x = $_x; $this->child =& $_child; //<<<<<<<<<< $this->child->m = "Grow up, son<br>"; } function foo() { return "I'm the parent.<br>"; } } class childClass { var $m; function childClass($_m) { $this->m = $_m; } function goo(){ return "I'm the child.<br>"; } } $son = new childClass("I want my mommy<br>"); $dad = new parentClass("I want a new Porche<br>", $son); echo $dad->child->goo(); echo $dad->child->m; echo $son->m; -- regards, Tom

« previous php.general (#126288) next »