note 16762 added to keyword.extends
| From: | roryo at mac dot com | Date: | Mon, 12 Nov 2001 16:33:37 +0000 |
| Subject: | note 16762 added to keyword.extends | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-20761@lists.php.net to get a copy of this message | ||
Here is a limitation of class inheritance: A subclass may call the constructor of its parent, but
its parent's constructor cannot call another function in the parent class.
class a {
function a() {
$this->init()
}
function init() {
print("hello from a!");
}
};
class b extends a {
function b() {
parent->a()
init();
}
function init() {
print("hello from b!");
}
};
$bb = new b();
will not print
hello from a
hello from b
but
hello from b
hello from b
--
http://www.php.net/manual/en/keyword.extends.php
http://master.php.net/manage/user-notes.php?action=edit+16762
http://master.php.net/manage/user-notes.php?action=delete+16762
http://master.php.net/manage/user-notes.php?action=reject+16762