PHP: How to Pass child class __construct() arguments to parent::__construct()? PHP: How to Pass child class __construct() arguments to parent::__construct()? php php

PHP: How to Pass child class __construct() arguments to parent::__construct()?


This can be done in PHP >= 5.6 without call_user_func_array() by using the ... (splat) operator:

public function __construct(){    parent::__construct(...func_get_args());}


There is something like this in php, though a bit verbose:

$args = func_get_args();call_user_func_array(array($this, 'parent::__construct'), $args);


if you get php nested limit error, try this:

$args = func_get_args();call_user_func_array(array('parent', '__construct'), $args);