3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Item { public static function &newWithParent(Item &$parent) { $item = new Item(); $item->parent = &$parent; return $item; } private $parent; public function &getParent() { return &$this->parent; } } $item = Item::newWithParent(Item::newWithParent(Item::newWithParent(new Item()))); // Basically it's this now: {"parent":{"parent":{"parent":{"parent":null}}}} // I want to set that null value $list = $item; do { $prev = &$item; $item = $item->getParent(); if ($item->getParent() === null) { $prev =& Item::newWithParent($item); break; } } while (true); var_dump($list);
Output for 5.3.0 - 5.4.15
Parse error: syntax error, unexpected '&' in /in/EQ8Pn on line 15
Process exited with code 255.