Last Updated: August 02, 2018
· wkjagt

A safe constructor in an extending class

Sometimes when you extend a class that's not yours, in a web framework for example, you need to have a constructor for your own class. You don't want to just put a constructor in there, because if the parent class has a constructor, it will be overridden. You could call parent::__construct() with the right arguments, but in a newer version of the the parent class, the signature of the constructor may change, and you would have broken it.

Python has *args and **kwargs for this, but in PHP the closest I have found is this:

call_user_func_array(array('parent', '__construct'), func_get_args());

1 Response
Add your response


Today you will be glad to know that here we are going to share one of the best portal http://windowstuts.net/synchronize-settings/ which will let you know about guidelines to sync settings windows 10 and will also help you to know how to use them in another windows 10.

3 months ago ·