construct

what is the purpose of construct method, which cannot be done by the new method. can anyone please explain with example in terms of layman.

I plan (for a long time already) to write an article about construct(). Unfortunately I haven’t done it so far…

Very briefly: Imagine you have a system class (SysClass) and you would like to extend it by your children class (MyClass extends SysClass) and use MyClass instead of SysClass everywhere.

If SysClass is constructed by a constructor (new()), you have to find all such places and replace new SysClass() with new MyClass(). If it used construct() method, you would replace just a single place - the constructor call in construct(). You can do more things in the construct() method, if you want, e.g. choosing the actual type to be constructed based on a condition.