3v4l.org

run code in 300+ PHP versions simultaneously
<?php function bar(iterable $opt = []){ var_dump($opt); } bar(); bar([0,1,2,3]); bar((function(){ yield from [0,1,2,3]; })());
Output for 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
array(0) { } array(4) { [0]=> int(0) [1]=> int(1) [2]=> int(2) [3]=> int(3) } object(Generator)#2 (1) { ["function"]=> string(21) "{closure:/in/avFmh:9}" }
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 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
array(0) { } array(4) { [0]=> int(0) [1]=> int(1) [2]=> int(2) [3]=> int(3) } object(Generator)#2 (0) { }
Output for 7.0.3 - 7.0.33
Fatal error: Default value for parameters with a class type can only be NULL in /in/avFmh on line 3
Process exited with code 255.
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.2
Fatal error: Default value for parameters with a class type hint can only be NULL in /in/avFmh on line 3
Process exited with code 255.

preferences:
130.56 ms | 1977 KiB | 4 Q