3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Item { public static $c = 0; public $i; public function __construct() { $this->i = self::$c; self::$c += 1; } } $collection = new \SplDoublyLinkedList(); $collection->add(0, new Item()); $collection->add(1, new Item()); foreach ($collection as $i=>$item) { echo $i . ' ' . $item->i . "\n"; }
based on bR27p
Output for 5.5.24 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
0 0 1 1
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.3.0 - 5.4.45
Fatal error: Call to undefined method SplDoublyLinkedList::add() in /in/YCTpO on line 14
Process exited with code 255.
Output for 5.0.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/YCTpO on line 12 Fatal error: Class 'SplDoublyLinkedList' not found in /in/YCTpO on line 12
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/YCTpO on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/YCTpO on line 4
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/YCTpO on line 4
Process exited with code 255.