note 5559 modified in language.oop by irc-html
| From: | irc-html@php.net | Date: | Sat, 19 Jan 2002 19:39:15 +0000 |
| Subject: | note 5559 modified in language.oop by irc-html | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-25265@lists.php.net to get a copy of this message | ||
The comment left by darkarena@idcomm.com is incorrect. A descendant class *CAN* call the constructor
of its parent. It's important to remember that the constructor is just a regular function. You
can call the constructor whenever you want.
class a {
function a()
{
echo "<H2> class a constructor</H2>";
}
}
class b extends a {
function b()
{
$this->a();
$this->a();
$this->a();
echo "<H2> class b constructor</H2>";
}
}
$object = new b();
--was--
The comment left by darkarena@idcomm.com is incorrect. A descendant class *CAN* call the constructor
of its parent. It's important to remember that the constructor is just a regular function. You
can call the constructor whenever you want.
<PRE>
class a {
function a()
{
echo "<H2> class a constructor</H2>";
}
}
class b extends a {
function b()
{
$this->a();
$this->a();
$this->a();
echo "<H2> class b constructor</H2>";
}
}
$object = new b();
</PRE>
http://www.php.net/manual/en/language.oop.php