note 51585 deleted from language.oop.constructor by danbrown
| From: | danbrown@php.net | Date: | Sat, 07 Nov 2009 18:57:18 +0000 |
| Subject: | note 51585 deleted from language.oop.constructor by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-162526@lists.php.net to get a copy of this message | ||
Note Submitter: phpnotes at ionws dot com
----
Just to possibly clarify something on this page: if you create an object of a derived class and the
derived class has no constructor, then the base class's constructor will be automatically
called. For example:
<?php
class A {
function A() {
echo "A()\n";
}
}
class B extends A {
function foo() {
}
}
$bar = new B;
// output: A()
?>
But if the derived class has a constructor, the base constructor is not automatically called. For
example:
<?php
class A {
function A() {
echo "A()\n";
}
}
class B extends A {
function B() {
echo "B()\n";
}
function foo() {
}
}
$bar = new B;
// output: B()
?>