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 getParent() { return $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 do { $item = $item->getParent(); if ($item->getParent() === null) { $item =& Item::newWithParent($item); break; } } while (true); var_dump($item);
Output for 5.4.0 - 5.4.15
Parse error: syntax error, unexpected 'getParent' (T_STRING), expecting variable (T_VARIABLE) in /in/lPFef on line 13
Process exited with code 255.
Output for 5.3.0 - 5.3.25
Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE in /in/lPFef on line 13
Process exited with code 255.