Paul Bissex wrote: > FWIW Python also requires child classes to call parent constructors > manually. Not sure what the justification is for this design decision > is, though, in either language. Anybody?
Flexibility, I would guess. With PHP's current behavior one can: (1) Call the parent constructor first, before the subclass constructor does its work. (2) Call the parent constructor last, after the subclass constructor does its work. (3) Call the parent constructor in the middle...doing some work before, and then some work after. :) (3) Pass through all of the subclass constructor's arguments to the parent constructor unaltered. (4) Change or filter some of the arguments that get passed to the parent constuctor. (5) Choose not to call the parent constructor at all. (6) Many other things that I'm sure I'm overlooking... If PHP called the parent constructor for you automagically, then how would you implement the above options? PHP would have to choose one approach and stick to it. I like the current behavior much better. Forgive me if this has been mentioned in this thread previously, but PHP does call the parent class constructor automatically if the subclass has no constuctor, which does make sense.... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php