note 58426 added to language.oop5.decon
| From: | derkAToneindigDOTcom at osu1 dot php dot net | Date: | Thu, 03 Nov 2005 22:02:23 +0000 |
| Subject: | note 58426 added to language.oop5.decon | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98042@lists.php.net to get a copy of this message | ||
If a constructor is not present in a child class, php5 will try to call a constructor from the
parent class. This behaviour can be used to somewhat simulate constructor chaining.
<?php
abstract class Parent {
function __construct()
{
echo "Parent constructor called\n";
$this->myConstruct();
}
}
class Child extends Parent {
function myConstruct()
{
echo " Child 'contructor' called";
}
}
$c = new Child();
?>
will output:
Parent constructor called
Child 'constructor' called
----
Manual Page -- http://www.php.net/manual/en/language.oop5.decon.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58426
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58426&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58426&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58426&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58426&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58426&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58426&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58426&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58426&report=yes
Search -- http://master.php.net/manage/user-notes.php