Re: php5 class initialization
| From: | Rasmus Lerdorf | Date: | Wed, 24 Mar 2004 08:56:41 +0000 |
| Subject: | Re: php5 class initialization | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-8739@lists.php.net to get a copy of this message | ||
On Wed, 24 Mar 2004, Stanislav Malyshev wrote:
> RL>> > Why the said people won't just insert the PHP5-specific code right into
> RL>> > the constructor? Why they need the second one?
> RL>>
> RL>> To avoid having it in 2 places.
>
> What is the second place? One plase is class() constructor, and the second
> one?
The example was something like:
class foo {
function foo() {
legacy generic constructor code
}
function __construct() {
php5-specific stuff
$this->foo(); // chain to legacy constructor code
}
}
A bit contrieved, but when this class runs under PHP5 it would run the
additional PHP5-specific code and when it runs under PHP4 it wouldn't.
-Rasmus