[PHP] Class and extends pb/bug? with php404pl1
I use PHP 4.0.4pl1 and I don't understand why this doesn't work. Does somebody help me ? class a { var $foo1 ; function a($thefoo) { $this-$foo1 = $thefoo ; echo a::foo1=.$this-$foo1.\n ; } } class b extends a { var $foo2 ; function b($thefoo1, $thefoo2) { $this-a($thefoo1) ; $this-$foo2 = $thefoo2 ; echo b::foo1=.$this-$foo1.\n ; echo b::foo2=.$this-$foo2.\n ; } } $toto = new b(1,3) ; echo FOO1=.$toto-$foo1.\n ; echo FOO2=.$toto-$foo2.\n ; The result is: a::foo1=1 b::foo1=3 - (and not 1) ??? b::foo2=3 FOO1=3- (and not 1) ??? FOO2=3 Many thanks for any information (perhaps I'm very tired and I understand nothing??) Hugues. -- Synaptique Europe www.synaptique.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Class and extends pb/bug? with php404pl1
use $this-foo1 no double dollar signs. Otherwise PHP thinks you are trying to do variable variables thing. Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: Hugues BRUNEL [mailto:[EMAIL PROTECTED]] Sent: Tuesday, May 22, 2001 6:55 PM To: [EMAIL PROTECTED] Subject: [PHP] Class and extends pb/bug? with php404pl1 I use PHP 4.0.4pl1 and I don't understand why this doesn't work. Does somebody help me ? class a { var $foo1 ; function a($thefoo) { $this-$foo1 = $thefoo ; echo a::foo1=.$this-$foo1.\n ; } } class b extends a { var $foo2 ; function b($thefoo1, $thefoo2) { $this-a($thefoo1) ; $this-$foo2 = $thefoo2 ; echo b::foo1=.$this-$foo1.\n ; echo b::foo2=.$this-$foo2.\n ; } } $toto = new b(1,3) ; echo FOO1=.$toto-$foo1.\n ; echo FOO2=.$toto-$foo2.\n ; The result is: a::foo1=1 b::foo1=3 - (and not 1) ??? b::foo2=3 FOO1=3- (and not 1) ??? FOO2=3 Many thanks for any information (perhaps I'm very tired and I understand nothing??) Hugues. -- Synaptique Europe www.synaptique.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Class and extends pb/bug? with php404pl1
On Tuesday 22 May 2001 11:54, Hugues BRUNEL wrote: echo b::foo1=.$this-$foo1.\n ; echo b::foo2=.$this-$foo2.\n ; You're accessing the fields incorrectly. It's $this-foo1 (without the second '$'). -- Christian Reiniger LGDC Webmaster (http://sunsite.dk/lgdc/) CPU not found. retry, abort, ignore? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]