Class Con- and Destructor Inheritance
| From: | Daniel Schierbeck | Date: | Sun, 22 Aug 2004 11:04:11 +0000 |
| Subject: | Class Con- and Destructor Inheritance | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-194416@lists.php.net to get a copy of this message | ||
Hello there. I was experimenting a bit with the constructors and destructors, and found that this code:
<?php
class First
{
public function __construct ()
{
echo "Hello, World!\n";
}
public function __destruct ()
{
echo "Goodbye, World!\n";
}
}
class Second extends First
{
}
$second = new Second;
?>
Outputs
Hello, World!
Goodbye, World!
, yet the PHP manual (http://www.php.net/manual/en/language.oop5.decon.php) says:
Note: Parent constructors are not called implicitly. In order
to run a parent constructor, a call to parent::__construct() is
required.
Is this an error in the manual or in PHP itself? Should I report it somewhere?