- var_dump: documentation ( source)
<?php
/* Function Argument Unpacking in PHP 5.6 complements Variadic Functions! */
class Foo {
public function __construct($arg1, $arg2, $arg3) {
/* Do stuff constructor with arguments */
$this->arg1 = $arg1;
$this->arg2 = $arg2;
$this->arg3 = $arg3;
}
}
class Bar extends Foo {
public function __construct(...$args) {
/**
* Before argument unpacking in 5.6 we would use
* call_user_func_array + func_get_args to accomplish
* the same thing.
*/
// The intent here is to call the parent constructor
parent::__construct(...$args); // Looks much nicer in 5.6
}
}
$bar = new Bar(1,2,3);
var_dump($bar);