Fairly straightforward question. In C++ the parent constructor will be implicitly called before the child constructor, so what logic is there for PHP not to do things this way?
EDIT: I've got a good answer from Lukman, but I was hoping for more of a reason why there is a difference. Maybe the question should be why does C++ not allow custom calling of parent constructors? I guess that's another question though.
I think it's a good thing that PHP makes you call parent's constructor manually, because it allows child's constructor such as following:
Or even:
Meaning, you are free to call the parent constructor anywhere within the child's and you are free to do stuff before and after the call. Ain't that a feature indeed?
When you don't have a constructor in the child class, then the parent one is automatically called.
If you decided to add a constructor to the child class, then of course you need to explicitly call the parent constructor. If you are already taking the time to add a constructor to your child class, then adding one more line of code
parent::__construct();
doesn't seem to be a big deal. But the overriding is actually a convenient flexibility.to avoid tight coupling that's why inheritance (extend keyword in java) is evil and interface class is prefered see Javaworld article: http://www.javaworld.com/javaworld/jw-08-2003/jw-0801-toolbox.html
Still it would be great if there was some instruction to call the parent at some point with a special keyword like forward but I have not yet seen this in any language (even Rebol) except in an unknown language invented by Paul Allen (yeah the co-founder of Microsoft) which is Openscript.