3v4l.org

run code in 500+ PHP versions simultaneously
<?php function main() : iterable { return []; } function main2() : iterable { yield 'Hello'; yield 'World'; return []; } foreach (main() as $line) { var_dump($line); } foreach (main2() as $line) { var_dump($line); }
Output for 7.2.24, 8.1.0 - 8.1.34, 8.2.0 - 8.2.32, 8.3.0 - 8.3.33, 8.4.1 - 8.4.24, 8.5.0 - 8.5.9
string(5) "Hello" string(5) "World"
Output for 4.3.11
Parse error: parse error, unexpected ':', expecting '{' in /in/KXste on line 3
Process exited with code 255.

preferences:
87.46 ms | 1033 KiB | 4 Q