3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $l = new SPLDoublyLinkedList(); $l->setIteratorMode(SplDoublyLinkedList::IT_MODE_DELETE); $l->setIteratorMode(SplDoublyLinkedList::IT_MODE_LIFO); $mode = $l->getIteratorMode(); var_dump("MODE: $mode"); var_dump("MODE CHECKS"); var_dump(($mode & SplDoublyLinkedList::IT_MODE_LIFO) == SplDoublyLinkedList::IT_MODE_LIFO); var_dump(($mode & SplDoublyLinkedList::IT_MODE_FIFO) == SplDoublyLinkedList::IT_MODE_FIFO); var_dump(($mode & SplDoublyLinkedList::IT_MODE_DELETE) == SplDoublyLinkedList::IT_MODE_DELETE); var_dump(($mode & SplDoublyLinkedList::IT_MODE_KEEP) == SplDoublyLinkedList::IT_MODE_KEEP); $l->push('A'); $l->push('B'); $l->push('C'); $l->push('D'); $l->rewind(); var_dump("Traversing"); var_dump($l->isEmpty()); var_dump($l->count()); var_dump($l->current()); $l->next(); var_dump($l->count()); var_dump($l->current()); $l->next(); var_dump($l->count()); var_dump($l->current()); $l->next(); var_dump($l->count()); var_dump($l->current()); $l->next(); var_dump($l->count()); var_dump($l->isEmpty());
based on BMLKD
Output for 5.3.0 - 7.1.0
string(7) "MODE: 2" string(11) "MODE CHECKS" bool(true) bool(true) bool(false) bool(true) string(10) "Traversing" bool(false) int(4) string(1) "D" int(4) string(1) "C" int(4) string(1) "B" int(4) string(1) "A" int(4) bool(false)
Output for 5.0.0 - 5.2.17
Fatal error: Class 'SPLDoublyLinkedList' not found in /in/a3iFn on line 2
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected ')', expecting '(' in /in/a3iFn on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected ')', expecting '(' in /in/a3iFn on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'('' in /in/a3iFn on line 3
Process exited with code 255.