#42370 [Opn->Bgs]: Inheritance problem
| From: | derick@php.net | Date: | Wed, 22 Aug 2007 08:44:16 +0000 |
| Subject: | #42370 [Opn->Bgs]: Inheritance problem | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-116450@lists.php.net to get a copy of this message | ||
ID: 42370
Updated by: derick@php.net
Reported By: chauhansudhir at fastmail dot in
-Status: Open
+Status: Bogus
Bug Type: Feature/Change Request
Operating System: Win XP
PHP Version: 5.2.3
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 how php works, you have to call parent::__construct() yourself.
Previous Comments:
------------------------------------------------------------------------
[2007-08-22 08:36:47] chauhansudhir at fastmail dot in
Description:
------------
When we inherit classes and creates an object of derieved class the
constructor of parent classes are not executed we need to execute this
explicitly. Please check the following code
Reproduce code:
---------------
<?php
abstract class a {
function __construct() {
print "a";
}
}
class b extends a {
function __construct() {
print "b";
}
}
class c extends b {
function __construct() {
print "c";
}
}
$v = new c();
?>
Expected result:
----------------
abc but it ab getting on c why so? as inheritance moves form parent to
child same as java.
Actual result:
--------------
c
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=42370&edit=1