Re: php5 class initialization
| From: | Stanislav Malyshev | Date: | Wed, 24 Mar 2004 09:57:12 +0000 |
| Subject: | Re: php5 class initialization | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-8745@lists.php.net to get a copy of this message | ||
CS>> I found the example a bad one too but the more I think about it the more
CS>> I believe that the language shouldn't stop you from designing your
CS>> classes in a way that you call the method which happens also to be a
CS>> constructor later again. And class methods (e.g. Log::log) are another
Why would you need to call constructor except when constructing object?
I imagine that's not a big problem to make constructor callable from any
context - but I just don't understand why would anyone want to call
the constructor after the object was already constructed?
CS>> The constructor should be nothing but a method which is called when
CS>> 'new' is invoked IMHO.
OK, right. So why to make some magic about which one is called when we
don't have any such magic in any other case when the method is called?
CS>> > Hm. Do you have some example of such code? Except for object cloning
CS>>
CS>> Uh oh, don't even mention object cloning or I'll start my sermon about
CS>> how badly PHP4 needs ->__clone() again (-:C
That's bad example since PHP5 syntax won't work in PHP4, so you need new
code in any case. I'm talking about code working _both_ in PHP4 and PHP5,
but behaving differently and that's only in constructor - otherwise you'd
need if()'s anyway, so no use to solve it just in the constructor.
--
Stanislav Malyshev, Zend Products Engineer
stas@zend.com http://www.zend.com/ +972-3-6139665 ext.109