Re: CLASS Problem

From: Date: Fri, 05 May 2000 19:01:47 +0000
Subject: Re: CLASS Problem
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-18466@lists.php.net to get a copy of this message
I know this isn't going to be much of a help but if you move the assignment of $this->table["ABC"] into the constructor, you will be able to reference it. As for referencing table in a member func, could it be that the scope of $u is lost when the recursive func unwinds? This might be the case since referencing table with $test->table["ABC"] is possible. Just a thought On Fri, 5 May 2000, Bocskai Stefan wrote: > > > Hi, > I'm a beginer in PHP and I already have a greate problem with the classes: > > Please see this example: > > <? > > class xx{ > var $child; > var $table = array(); > var $i; > > function xx($i){ > $this->i = $i; > if ($i<10) $this->child = new xx($i+1); > > }// end of constructor > > > function propag() > { > // this function is auto porpaging into objects > // and set the value of $table["ABC"]; > $this->table["ABC"] = "1234567890"; > $u = $this->child; > if (gettype($u) == "object" ) > $u->propag(); > } > > > }//end of class xx > > > // and then .... > > $test = new xx(0); > $test->propag(); > > $child = $test->child; > > $child2 = $child->child; > > echo "The value of child is : ".$child2->table["ABC"]; > echo "<br> level: ".$child2->i; > > ?> > > Whay I cannot see the value of table["ABC"]? At the same time the > "level" apear .... > > > Thank you, > Bebe > > > > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > Randy Jonasz Software Engineer Click2net Inc. Web: http://www.click2net.com Phone: (905) 271-3550 "You cannot possibly pay a philosopher what he's worth, but try your best" -- Aristotle

« previous php.dev (#18466) next »