Bug #16847 Updated: initialization function in extended class resets parent class variables
| From: | mfischer@php.net | Date: | Fri, 26 Apr 2002 11:43:01 +0000 |
| Subject: | Bug #16847 Updated: initialization function in extended class resets parent class variables | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-6091@lists.php.net to get a copy of this message | ||
ID: 16847
Updated by: mfischer@php.net
Reported By: alexg@syspro.co.za
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: linux 2.4.0
PHP Version: 4.1.2
New Comment:
You have to call the parents constructor explicitely. That's by design.
Previous Comments:
------------------------------------------------------------------------
[2002-04-26 06:54:40] alexg@syspro.co.za
When including an initialization function within both A and B classes,
creating an instance of he extending B class resets the variable
value created by initialization function withing the A class
class A {
var $var_a;
function A() {
$this->var_a = "a";
}
}
class B extends A {
var $var_b;
function B() {
$this->var_b = "b";
}
}
$test = new B;
echo $test->var_a; //no output unless I comment out function B() in
class B
echo $test->var_b;
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=16847&edit=1