#27476 [Opn->Bgs]: Extends and parent vars
| From: | derick@php.net | Date: | Wed, 03 Mar 2004 09:42:24 +0000 |
| Subject: | #27476 [Opn->Bgs]: Extends and parent vars | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-55839@lists.php.net to get a copy of this message | ||
ID: 27476
Updated by: derick@php.net
Reported By: agigames at agigames dot com
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: Windows XP
PHP Version: 5.0.0b4 (beta4)
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This is correct, PHP will not automatically call the parent constructor
if you do:
$obj2 = new childclass;
Previous Comments:
------------------------------------------------------------------------
[2004-03-02 23:23:53] agigames at agigames dot com
Description:
------------
This problem occurs in both PHP 4.3.5RC3 and in PHP 5.0.0b4. The
constructor function of the child class does not have the proper var's
set in it from the parent class.
Reproduce code:
---------------
class parentclass {
public $var = 'test';
function parentclass() {
$this->var = 'test2';
}
}
class childclass extends parentclass {
function childclass() {
print $this->var;
}
}
$obj = new parentclass;
$obj2 = new childclass;
Expected result:
----------------
Well I expected it to print "test2".
Actual result:
--------------
But instead it prints the value that the public var was initialized as
"test".
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27476&edit=1