3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function foo() { foreach ([] as $foo) { yield $foo; } } $iterator = new AppendIterator(); $iterator->append(foo()); var_dump(iterator_to_array($iterator));
Output for 7.0.20 - 7.2.0
Fatal error: Uncaught Exception: Cannot traverse an already closed generator in /in/b5gnm:10 Stack trace: #0 [internal function]: AppendIterator->rewind() #1 /in/b5gnm(10): iterator_to_array(Object(AppendIterator)) #2 {main} thrown in /in/b5gnm on line 10
Process exited with code 255.
Output for 5.5.24 - 5.6.21, 7.0.0 - 7.0.6

Process exited with code 139.
Output for 5.6.28
Fatal error: Uncaught exception 'Exception' with message 'Cannot traverse an already closed generator' in /in/b5gnm:10 Stack trace: #0 [internal function]: AppendIterator->rewind() #1 /in/b5gnm(10): iterator_to_array(Object(AppendIterator)) #2 {main} thrown in /in/b5gnm on line 10
Process exited with code 255.
Output for 5.4.12 - 5.4.45
Parse error: syntax error, unexpected '$foo' (T_VARIABLE) in /in/b5gnm on line 5
Process exited with code 255.
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/b5gnm on line 4
Process exited with code 255.