Re: Classes

From: Date: Wed, 09 Apr 2003 14:35:52 +0000
Subject: Re: Classes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-143090@lists.php.net to get a copy of this message
In addition, this will result in the same...what do i wrong? <?php class a { var $text1; var $text2; function a() { $this->$text1 = ""; $this->$text2 = "Hi"; } function SetText1($text) { $this->$text1 = $text; } function GetText1() { return $this->$text1; } function SetText2($text) { $this->$text2 = $text; } function GetText2() { return $this->$text2; } } $me = new a; echo $me->GetText1() . "<br>"; echo $me->GetText2() . "<br>"; ?> "Remco Brouwer" <formza@xs4all.nl> schreef in bericht news:20030409140430.6473.qmail@pb1.pair.com... > Hi all, why is the output of this code : > Hi > Hi > > Thx in advance, R.Brouwer > > ---------start--------- > class a { > var $text1; > var $text2; > > function SetText1($text) { > $this->$text1 = $text; > } > > function SetText2($text) { > $this->$text2 = $text; > } > } > > class b extends a { > function Test() { > $this->SetText2("Hi"); > echo $this->$text1 . "<br>"; > echo $this->$text2 . "<br>"; > } > } > > $a = new b; > $a->test(); > > ---------end--------- > Hi > Hi > > >

« previous php.general (#143090) next »