Re: PHP 4.0 Bug #2675 Updated: Misbehavior of object initializers

From: Date: Sat, 06 Nov 1999 19:32:04 +0000
Subject: Re: PHP 4.0 Bug #2675 Updated: Misbehavior of object initializers
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-12183@lists.php.net to get a copy of this message
At 10:57 AM 11/6/99 -0600, ZeroDiVide wrote:
You should use the Factory design pattern I suppose. How about the following: And then do something like (actually it doesn't even need to be $new_db = DB::Factory('mysql'); So i guess the larger question here is are we doing java symantics or c++ ?
PHP semantics :) I'm not sure what you can do in Java with constructors, but in this case, PHP is similar to C++.
Maybee i don't understand the whole issue here, but i thought the point of overloading the constructor was to do whatever you want with it. Including stupid stuff like returning another object.
No it isn't. The point of overloading a constructor is to initialize the object ($this) with whatever default values you want. If you're doing inheritance and you need a new constructor for the offspring class, you might want to call the parent's constructor in addition to the added code of your new constructor. It's up to the developer to decide what exactly he wants to do. Andi --- Andi Gutmans <andi@zend.com> http://www.zend.com/

« previous php.dev (#12183) next »