3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function foo() { foreach ([] as $foo) { } } $iterator = new AppendIterator(); $iterator->append(foo()); var_dump(iterator_to_array($iterator));
based on q3I67
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught TypeError: Argument 1 passed to AppendIterator::append() must implement interface Iterator, null given in /in/V0F0K:8 Stack trace: #0 /in/V0F0K(8): AppendIterator->append(NULL) #1 {main} thrown in /in/V0F0K on line 8
Process exited with code 255.
Output for 5.4.12 - 5.6.28
Catchable fatal error: Argument 1 passed to AppendIterator::append() must implement interface Iterator, null given in /in/V0F0K on line 8
Process exited with code 255.
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/V0F0K on line 3
Process exited with code 255.