3v4l.org

run code in 300+ PHP versions simultaneously
<?php function a() { return [ 100 => 'first', 101 => 'second', 102 => 'third', 'named' => 'fourth', ]; } function b() { yield 100 => 'first'; yield 101 => 'second'; yield 102 => 'third'; yield 'named' => 'fourth'; } function c() { yield '100' => 'first'; yield '101' => 'second'; yield '102' => 'third'; yield 'named' => 'fourth'; } function test($x=null, $y=null, ...$z) { var_dump($x, $y, $z); } test(...a()); echo "\n"; test(...b()); echo "\n"; test(...c());
Output for 8.3.25 - 8.3.28, 8.4.12 - 8.4.14, 8.5.0
string(5) "first" string(6) "second" array(2) { [0]=> string(5) "third" ["named"]=> string(6) "fourth" } string(5) "first" string(6) "second" array(2) { [0]=> string(5) "third" ["named"]=> string(6) "fourth" } string(5) "first" string(6) "second" array(2) { [0]=> string(5) "third" ["named"]=> string(6) "fourth" }
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.2.0 - 8.2.29, 8.3.0 - 8.3.24, 8.4.1 - 8.4.11
string(5) "first" string(6) "second" array(2) { [0]=> string(5) "third" ["named"]=> string(6) "fourth" } string(5) "first" string(6) "second" array(2) { [0]=> string(5) "third" ["named"]=> string(6) "fourth" } NULL NULL array(4) { ["100"]=> string(5) "first" ["101"]=> string(6) "second" ["102"]=> string(5) "third" ["named"]=> string(6) "fourth" }

preferences:
62.76 ms | 410 KiB | 5 Q