3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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); }
based on k0IBO
Output for 7.0.0 - 7.2.0
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.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.
Output for 5.3.18 - 5.3.29
Warning: Unsupported declare 'strict_types' in /in/CqQtL on line 3 Parse error: syntax error, unexpected '[' in /in/CqQtL on line 10
Process exited with code 255.