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()); iterator_to_array($iterator);
based on 3UbjS
Output for 7.0.20 - 7.2.0
Fatal error: Uncaught Exception: Cannot traverse an already closed generator in /in/NpYef:9 Stack trace: #0 [internal function]: AppendIterator->rewind() #1 /in/NpYef(9): iterator_to_array(Object(AppendIterator)) #2 {main} thrown in /in/NpYef on line 9
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/NpYef:9 Stack trace: #0 [internal function]: AppendIterator->rewind() #1 /in/NpYef(9): iterator_to_array(Object(AppendIterator)) #2 {main} thrown in /in/NpYef on line 9
Process exited with code 255.
Output for 5.4.12 - 5.4.45
Parse error: syntax error, unexpected '$foo' (T_VARIABLE) in /in/NpYef on line 4
Process exited with code 255.
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/NpYef on line 3
Process exited with code 255.