3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php declare(strict=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 7MtFv
Output for 7.0.0 - 7.2.0
Warning: Unsupported declare 'strict' in /in/k0IBO on line 3 int(1) 1 => 1 int(2) 2 => 2 int(3) 3 => 3
Output for 5.4.2 - 5.6.28
Warning: Unsupported declare 'strict' in /in/k0IBO on line 3 int(1) Catchable fatal error: Argument 1 passed to doStuff() must be an instance of string, integer given, called in /in/k0IBO on line 18 and defined in /in/k0IBO on line 5
Process exited with code 255.
Output for 5.3.18 - 5.3.29
Warning: Unsupported declare 'strict' in /in/k0IBO on line 3 Parse error: syntax error, unexpected '[' in /in/k0IBO on line 10
Process exited with code 255.