3v4l.org

run code in 300+ PHP versions simultaneously
<?php function test($array) { try { return isDictionary($array); } catch (Exception $e) { echo $e->getMessage(); return 'error'; } } function isDictionary($array) { return !(bool)count(array_filter(array_keys($array), 'is_string')); } $arr = 0; var_dump(test($arr));
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
Fatal error: Uncaught TypeError: array_keys(): Argument #1 ($array) must be of type array, int given in /in/tOFqo:17 Stack trace: #0 /in/tOFqo(17): array_keys(0) #1 /in/tOFqo(7): isDictionary(0) #2 /in/tOFqo(23): test(0) #3 {main} thrown in /in/tOFqo on line 17
Process exited with code 255.
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: array_keys() expects parameter 1 to be array, int given in /in/tOFqo on line 17 Warning: array_filter() expects parameter 1 to be array, null given in /in/tOFqo on line 17 Warning: count(): Parameter must be an array or an object that implements Countable in /in/tOFqo on line 17 bool(true)
Output for 7.2.0 - 7.2.33
Warning: array_keys() expects parameter 1 to be array, integer given in /in/tOFqo on line 17 Warning: array_filter() expects parameter 1 to be array, null given in /in/tOFqo on line 17 Warning: count(): Parameter must be an array or an object that implements Countable in /in/tOFqo on line 17 bool(true)
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25
Warning: array_keys() expects parameter 1 to be array, integer given in /in/tOFqo on line 17 Warning: array_filter() expects parameter 1 to be array, null given in /in/tOFqo on line 17 bool(true)

preferences:
162.42 ms | 402 KiB | 198 Q