3v4l.org

run code in 300+ PHP versions simultaneously
<?php function gen(): Generator { yield fn($a) => 'b' => 'c'; } gen(); foreach(gen() as $key => $value) { var_dump($key, $value); }
based on sbeOf

Shows result from various feature-branches currently under review from the php developers. Contact me to have additional branches featured.

Output for branch master
object(Closure)#3 (1) { ["parameter"]=> array(1) { ["$a"]=> string(10) "<required>" } } string(1) "c"
Output for branch master_jit
object(Closure)#3 (1) { ["parameter"]=> array(1) { ["$a"]=> string(10) "<required>" } } string(1) "c"
Output for branch enumerations
object(Closure)#3 (1) { ["parameter"]=> array(1) { ["$a"]=> string(10) "<required>" } } string(1) "c"

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page