Re: constructors are callable as regular functions.
| From: | Edward Z. Yang | Date: | Thu, 02 Jul 2009 14:47:44 +0000 |
| Subject: | Re: constructors are callable as regular functions. | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-44658@lists.php.net to get a copy of this message | ||
Excerpts from troels knak-nielsen's message of Thu Jul 02 10:14:18 -0400 2009:
> I would have expected the second call to __construct() to yield an error.
Why should it? Especially since this is idiomatic code:
class A {
public function __construct($a) {
$this->a = $a;
}
}
class B extends A {
public function __construct($a, $b) {
$this->b = $b;
parent::__construct($a);
}
}
__construct doesn't do anything like allocate memory. It just happens
to get called when we do "new B(1, 2)"
Cheers,
Edward