3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function foo($data) { foreach ($data as $foo) { yield $foo; } } $iterator = new AppendIterator(); $iterator->append(foo([])); iterator_to_array($iterator);
Output for 7.0.20 - 7.2.0
Fatal error: Uncaught Exception: Cannot traverse an already closed generator in /in/3UbjS:9 Stack trace: #0 [internal function]: AppendIterator->rewind() #1 /in/3UbjS(9): iterator_to_array(Object(AppendIterator)) #2 {main} thrown in /in/3UbjS 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/3UbjS:9 Stack trace: #0 [internal function]: AppendIterator->rewind() #1 /in/3UbjS(9): iterator_to_array(Object(AppendIterator)) #2 {main} thrown in /in/3UbjS 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/3UbjS on line 4
Process exited with code 255.
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected T_VARIABLE in /in/3UbjS on line 4
Process exited with code 255.