<?php class Car { private $color; private $size; public function __construct($color, $size) { $this->color = $color; $this->size = $size; } public function describe() { return "A $this->size $this->color car."; } } $callable = [new \ReflectionClass('Car'), 'newInstance']; $cars = []; $cars[] = call_user_func($callable, 'red', 'big')->describe(); $cars[] = call_user_func_array($callable, ['blue', 'small'])->describe(); var_export($cars);
You have javascript disabled. You will not be able to edit any code.