note 31476 added to language.oop
| From: | yaroukh at email dot cz | Date: | Wed, 23 Apr 2003 13:21:20 +0000 |
| Subject: | note 31476 added to language.oop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-46980@lists.php.net to get a copy of this message | ||
to Mad Murdock:
@ 06-Mar-2003 08:34 you wrote:
"this line is not needed as the ParentObject funtion is a constructor for ParentObject class,
which MemberObject is extending. Thus, it inherits it and since it is a constructor, it is executed
automatically."
I think you're wrong. A constructor of the "parent" class is being called only if the
"child" class constructor is not found.
Following example prooves this - the Parent's constructor is not being executed and the output
is only: "here I am - Child constructor"
<?..class Parent {
........function Parent() {
............print "here I am - Parent constructor";
........}
....}
....class Child extends Parent {
........function Child() {
............print "here I am - Child constructor";
........}
....}
....$child =& new Child();
?>
Have a nice day
Yaroukh
--
http://www.php.net/manual/en/language.oop.php
http://master.php.net/manage/user-notes.php?action=edit+31476
http://master.php.net/manage/user-notes.php?action=delete+31476
http://master.php.net/manage/user-notes.php?action=reject+31476