3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); function doStuff(string $key, string $value) { echo "{$key} => {$value}\n"; } $array = [ '1' => '1', '2' => '2', '3' => '3', ]; foreach ($array as $key => $value) { var_dump($key); doStuff($key, $value); }
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.6
int(1) Fatal error: Uncaught TypeError: doStuff(): Argument #1 ($key) must be of type string, int given, called in /in/CqQtL on line 18 and defined in /in/CqQtL:5 Stack trace: #0 /in/CqQtL(18): doStuff(1, '1') #1 {main} thrown in /in/CqQtL on line 5
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
int(1) Fatal error: Uncaught TypeError: Argument 1 passed to doStuff() must be of the type string, int given, called in /in/CqQtL on line 18 and defined in /in/CqQtL:5 Stack trace: #0 /in/CqQtL(18): doStuff(1, '1') #1 {main} thrown in /in/CqQtL on line 5
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33
int(1) Fatal error: Uncaught TypeError: Argument 1 passed to doStuff() must be of the type string, integer given, called in /in/CqQtL on line 18 and defined in /in/CqQtL:5 Stack trace: #0 /in/CqQtL(18): doStuff(1, '1') #1 {main} thrown in /in/CqQtL on line 5
Process exited with code 255.
Output for 5.4.2 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28
Warning: Unsupported declare 'strict_types' in /in/CqQtL on line 3 int(1) Catchable fatal error: Argument 1 passed to doStuff() must be an instance of string, integer given, called in /in/CqQtL on line 18 and defined in /in/CqQtL on line 5
Process exited with code 255.

preferences:
219.26 ms | 402 KiB | 273 Q