3v4l.org

run code in 300+ PHP versions simultaneously
<?php //$bar = array_merge(...['a' => ['b', 'c']]); $ref = new \ReflectionFunction('array_merge'); foreach ($ref->getParameters() as $p) { var_dump($p->getName()); var_dump($p->isOptional()); var_dump($p->isVariadic()); var_dump('---'); } function foo(...$arrays): void { } foo(...['a' => ['b', 'c']]); // works array_merge(...['a' => ['b', 'c']]); // doesn't
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6 - 8.3.7
string(6) "arrays" bool(true) bool(true) string(3) "---" Fatal error: Uncaught ArgumentCountError: array_merge() does not accept unknown named parameters in /in/bQrhZ:19 Stack trace: #0 /in/bQrhZ(19): array_merge(a: Array) #1 {main} thrown in /in/bQrhZ on line 19
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 string(6) "arrays" bool(true) bool(true) string(3) "---" Fatal error: Uncaught ArgumentCountError: array_merge() does not accept unknown named parameters in /in/bQrhZ:19 Stack trace: #0 /in/bQrhZ(19): array_merge(a: Array) #1 {main} thrown in /in/bQrhZ on line 19
Process exited with code 255.
Output for 7.4.0 - 7.4.33
string(6) "arrays" bool(true) bool(true) string(3) "---" Fatal error: Uncaught Error: Cannot unpack array with string keys in /in/bQrhZ:18 Stack trace: #0 {main} thrown in /in/bQrhZ on line 18
Process exited with code 255.
Output for 7.2.6 - 7.2.34, 7.3.0 - 7.3.33
string(4) "arr1" bool(false) bool(false) string(3) "---" string(6) "arrays" bool(true) bool(true) string(3) "---" Fatal error: Uncaught Error: Cannot unpack array with string keys in /in/bQrhZ:18 Stack trace: #0 {main} thrown in /in/bQrhZ on line 18
Process exited with code 255.
Output for 7.2.0 - 7.2.5
string(4) "arr1" bool(false) bool(false) string(3) "---" string(6) "arrays" bool(false) bool(true) string(3) "---" Fatal error: Uncaught Error: Cannot unpack array with string keys in /in/bQrhZ:18 Stack trace: #0 {main} thrown in /in/bQrhZ on line 18
Process exited with code 255.

preferences:
193.1 ms | 402 KiB | 184 Q