3v4l.org

run code in 500+ PHP versions simultaneously
<?php function foo() { yield 'foo'; goo(); } function too() { yield 'too'; yield from goo(); } function hoo() { yield 'hoo'; yield goo(); } function goo() { yield 'goo'; } foreach(foo() as $a) { print $a.PHP_EOL;} // goo foreach(too() as $a) { print $a.PHP_EOL;} // too goo foreach(hoo() as $a) { print $a.PHP_EOL;} // hoo Uncaught Error: Object of class Generator // could not be converted to string ?>
Output for 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.21, 8.5.0 - 8.5.6
foo too goo hoo Fatal error: Uncaught Error: Object of class Generator could not be converted to string in /in/Znbbl:26 Stack trace: #0 {main} thrown in /in/Znbbl on line 26
Process exited with code 255.

preferences:
35.5 ms | 865 KiB | 4 Q