3v4l.org

run code in 300+ PHP versions simultaneously
<?php $initialGen = function () : iterable { yield 1; yield 2; yield 3; }; var_dump($initialGen); $initialGen = $initialGen(); var_dump($initialGen); function map (callable $f, iterable $xs) : array { return []; } map(function ($x) { return $x * 2; }, $initialGen);
Output for 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
object(Closure)#1 (3) { ["name"]=> string(21) "{closure:/in/kN6a9:3}" ["file"]=> string(9) "/in/kN6a9" ["line"]=> int(3) } object(Generator)#2 (1) { ["function"]=> string(21) "{closure:/in/kN6a9:3}" }
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.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30
object(Closure)#1 (0) { } object(Generator)#2 (0) { }
Output for 5.6.38
Parse error: syntax error, unexpected ':', expecting '{' in /in/kN6a9 on line 3
Process exited with code 255.

preferences:
104.99 ms | 1460 KiB | 4 Q