3v4l.org

run code in 200+ php & hhvm versions
<?php function e($s) { $line = debug_backtrace()[0]['line']; echo str_pad((string) $line, 2, ' ', STR_PAD_LEFT) . ': ' . str_pad($s, 15, ' ', STR_PAD_LEFT) . ': '; } $a = new ArrayIterator(); $a->rewind(); e('valid()' ); var_dump($a->valid()); e('current()' ); var_dump($a->current()); e('offsetSet(2, 2)'); var_dump($a->offsetSet(2, 2)); e('valid()' ); var_dump($a->valid()); e('current()' ); var_dump($a->current()); e('next()' ); var_dump($a->next()); e('valid()' ); var_dump($a->valid()); e('current()' ); var_dump($a->current()); e('offsetSet(5, 5)'); var_dump($a->offsetSet(5, 5)); e('valid()' ); var_dump($a->valid()); e('current()' ); var_dump($a->current()); e($a->current()); echo PHP_EOL; e('next()' ); var_dump($a->next()); e('valid()' ); var_dump($a->valid()); e('current()' ); var_dump($a->current()); e('next()' ); var_dump($a->next()); e('valid()' ); var_dump($a->valid()); e('current()' ); var_dump($a->current()); e('offsetSet(8, 8)'); var_dump($a->offsetSet(8, 8)); e('valid()' ); var_dump($a->valid()); e('current()' ); var_dump($a->current()); e('next()' ); var_dump($a->next()); e('valid()' ); var_dump($a->valid()); e('current()' ); var_dump($a->current()); e('next()' ); var_dump($a->next()); e('valid()' ); var_dump($a->valid()); e('current()' ); var_dump($a->current()); e('offsetSet(7, 7)'); var_dump($a->offsetSet(7, 7)); e('valid()' ); var_dump($a->valid()); e('current()' ); var_dump($a->current()); e('next()' ); var_dump($a->next()); e('valid()' ); var_dump($a->valid()); e('current()' ); var_dump($a->current()); e('next()' ); var_dump($a->next()); e('valid()' ); var_dump($a->valid()); e('current()' ); var_dump($a->current());
Output for hhvm-3.10.1 - 3.21.3, 7.0.0 - 7.2.18, 7.3.5
9: valid(): bool(false) 10: current(): NULL 11: offsetSet(2, 2): NULL 12: valid(): bool(true) 13: current(): int(2) 14: next(): NULL 15: valid(): bool(false) 16: current(): NULL 17: offsetSet(5, 5): NULL 18: valid(): bool(true) 19: current(): int(5) 20: 5: 21: next(): NULL 22: valid(): bool(false) 23: current(): NULL 24: next(): NULL 25: valid(): bool(false) 26: current(): NULL 27: offsetSet(8, 8): NULL 28: valid(): bool(true) 29: current(): int(8) 30: next(): NULL 31: valid(): bool(false) 32: current(): NULL 33: next(): NULL 34: valid(): bool(false) 35: current(): NULL 36: offsetSet(7, 7): NULL 37: valid(): bool(true) 38: current(): int(7) 39: next(): NULL 40: valid(): bool(false) 41: current(): NULL 42: next(): NULL 43: valid(): bool(false) 44: current(): NULL
Output for 7.3.0 - 7.3.4
9: valid(): bool(false) 10: current(): NULL 11: offsetSet(2, 2): NULL 12: valid(): bool(true) 13: current(): int(2) 14: next(): NULL 15: valid(): bool(false) 16: current(): NULL 17: offsetSet(5, 5): NULL 18: valid(): bool(true) 19: current(): UNKNOWN:0 Notice: Undefined variable: s in /in/Ft0Dh on line 5 20: : 21: next(): NULL 22: valid(): bool(true) 23: current(): int(5) 24: next(): NULL 25: valid(): bool(false) 26: current(): NULL 27: offsetSet(8, 8): NULL 28: valid(): bool(false) 29: current(): NULL 30: next(): NULL 31: valid(): bool(false) 32: current(): NULL 33: next(): NULL 34: valid(): bool(false) 35: current(): NULL 36: offsetSet(7, 7): NULL 37: valid(): bool(false) 38: current(): NULL 39: next(): NULL 40: valid(): bool(false) 41: current(): NULL 42: next(): NULL 43: valid(): bool(false) 44: current(): NULL
Output for hhvm-3.22.0
-1: valid(): bool(false) -1: current(): NULL -1: offsetSet(2, 2): NULL -1: valid(): bool(true) -1: current(): int(2) -1: next(): NULL -1: valid(): bool(false) -1: current(): NULL -1: offsetSet(5, 5): NULL -1: valid(): bool(true) -1: current(): int(5) -1: 5: -1: next(): NULL -1: valid(): bool(false) -1: current(): NULL -1: next(): NULL -1: valid(): bool(false) -1: current(): NULL -1: offsetSet(8, 8): NULL -1: valid(): bool(true) -1: current(): int(8) -1: next(): NULL -1: valid(): bool(false) -1: current(): NULL -1: next(): NULL -1: valid(): bool(false) -1: current(): NULL -1: offsetSet(7, 7): NULL -1: valid(): bool(true) -1: current(): int(7) -1: next(): NULL -1: valid(): bool(false) -1: current(): NULL -1: next(): NULL -1: valid(): bool(false) -1: current(): NULL
Output for 5.4.0 - 5.6.40
9: valid(): bool(false) 10: current(): NULL 11: offsetSet(2, 2): NULL 12: valid(): bool(false) 13: current(): NULL 14: next(): NULL 15: valid(): bool(false) 16: current(): NULL 17: offsetSet(5, 5): NULL 18: valid(): bool(false) 19: current(): NULL 20: : 21: next(): NULL 22: valid(): bool(false) 23: current(): NULL 24: next(): NULL 25: valid(): bool(false) 26: current(): NULL 27: offsetSet(8, 8): NULL 28: valid(): bool(false) 29: current(): NULL 30: next(): NULL 31: valid(): bool(false) 32: current(): NULL 33: next(): NULL 34: valid(): bool(false) 35: current(): NULL 36: offsetSet(7, 7): NULL 37: valid(): bool(false) 38: current(): NULL 39: next(): NULL 40: valid(): bool(false) 41: current(): NULL 42: next(): NULL 43: valid(): bool(false) 44: current(): NULL
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/Ft0Dh on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/Ft0Dh on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/Ft0Dh on line 3
Process exited with code 255.