3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Item { public $name; public $parent; public function __construct($name, $parent = null) { $this->name = $name; $this->parent = $parent; } } function render(Item $item) { yield $item; while (is_object($item) { if ($item->parent) { yield from render($item->parent); } } } $a = new Item('a'); $b = new Item('b', $a); $c = new Item('c', $b); $d = new Item('d', $c); $e = new Item('e', $d); foreach (render($e) as $item) { var_dump($item); }
based on MlYOb
Output for 7.0.0
Parse error: syntax error, unexpected 'if' (T_IF) in /in/A4gTJ on line 21
Process exited with code 255.
Output for 5.5.24 - 5.6.16
Parse error: syntax error, unexpected '{' in /in/A4gTJ on line 20
Process exited with code 255.
Output for 5.4.10 - 5.4.45
Parse error: syntax error, unexpected '$item' (T_VARIABLE) in /in/A4gTJ on line 18
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected T_VARIABLE in /in/A4gTJ on line 18
Process exited with code 255.