3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Wagon { private $name; public function setName($name){ $this->name = $name; } public function getName(){ return $this->name; } } class Train { public function __construct(array $wagons) { $this->wagons = (function (Wagon $wagons) { return $wagons->getName(); })($wagons); } } $vagon = new Wagon(); $vagon->setName('vagon 1'); var_dump(new Train([$vagon]));
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: Train::{closure}(): Argument #1 ($wagons) must be of type Wagon, array given, called in /in/h9X1j on line 21 and defined in /in/h9X1j:19 Stack trace: #0 /in/h9X1j(21): Train->{closure}(Array) #1 /in/h9X1j(29): Train->__construct(Array) #2 {main} thrown in /in/h9X1j on line 19
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
56.5 ms | 401 KiB | 8 Q