Re: constructors are callable as regular functions.
| From: | Kalle Sommer Nielsen | Date: | Thu, 02 Jul 2009 15:07:36 +0000 |
| Subject: | Re: constructors are callable as regular functions. | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-44663@lists.php.net to get a copy of this message | ||
2009/7/2 troels knak-nielsen <troelskn@gmail.com>:
> [snip] ... - I don't remember ever
> seen __construct() called directly.
Its commonly done when extending reflection for example, or to
populate the Exception class constructor when extending it:
<?php
class TestException extends Exception
{
public function __construct($code, $message)
{
$this->code = (integer) $code;
parent::__construct($message);
}
}
?>
Or more complex constructors without having to re-implement their
logic / handling of constructing the object.
--
regrads,
Kalle Sommer Nielsen
kalle@php.net