3v4l.org

run code in 300+ PHP versions simultaneously
<?php $it = (function () { if (false) { yield 'foo'; }})(); var_dump($it->valid()); foreach ($it as $k => $v) { var_dump($k, $v); }
Output for 7.1.0 - 7.1.24, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.26, 8.0.0 - 8.0.13, 8.1rc1 - rc3
bool(false) Fatal error: Uncaught Exception: Cannot traverse an already closed generator in /in/2E7EJ:7 Stack trace: #0 {main} thrown in /in/2E7EJ on line 7
Process exited with code 255.
Output for 5.6.38
Parse error: syntax error, unexpected '(' in /in/2E7EJ on line 3
Process exited with code 255.

preferences:
30.91 ms | 460 KiB | 5 Q