3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $keys = array(0, "", "0", 0.0, false, null, array()); foreach ($keys as $key) { $array = array($key => "foo"); var_dump($key); var_dump(key($array)); var_dump(isset($array[$key])); var_dump(array_key_exists($key, $array)); echo "\n"; }
Output for 5.1.0 - 5.6.28, 7.0.0 - 7.1.0
int(0) int(0) bool(true) bool(true) string(0) "" string(0) "" bool(true) bool(true) string(1) "0" int(0) bool(true) bool(true) float(0) int(0) bool(true) Warning: array_key_exists(): The first argument should be either a string or an integer in /in/vltnn on line 8 bool(false) bool(false) int(0) bool(true) Warning: array_key_exists(): The first argument should be either a string or an integer in /in/vltnn on line 8 bool(false) NULL string(0) "" bool(true) bool(true) Warning: Illegal offset type in /in/vltnn on line 4 array(0) { } NULL Warning: Illegal offset type in isset or empty in /in/vltnn on line 7 bool(false) Warning: array_key_exists(): The first argument should be either a string or an integer in /in/vltnn on line 8 bool(false)
Output for hhvm-3.12.0
int(0) int(0) bool(true) bool(true) string(0) "" string(0) "" bool(true) bool(true) string(1) "0" int(0) bool(true) bool(true) float(0) int(0) bool(true) Warning: Array key should be either a string or an integer in /in/vltnn on line -1 bool(false) bool(false) int(0) bool(true) Warning: Array key should be either a string or an integer in /in/vltnn on line -1 bool(false) NULL string(0) "" bool(true) bool(true) Warning: Invalid operand type was used: Invalid type used as key in /in/vltnn on line -1 array(0) { } NULL Warning: Invalid operand type was used: Invalid type used as key in /in/vltnn on line -1 bool(false) Warning: Array key should be either a string or an integer in /in/vltnn on line -1 bool(false)
Output for hhvm-3.10.0
int(0) int(0) bool(true) bool(true) string(0) "" string(0) "" bool(true) bool(true) string(1) "0" int(0) bool(true) bool(true) float(0) int(0) bool(true) Warning: Array key should be either a string or an integer in /in/vltnn on line 8 bool(false) bool(false) int(0) bool(true) Warning: Array key should be either a string or an integer in /in/vltnn on line 8 bool(false) NULL string(0) "" bool(true) bool(true) Warning: Invalid operand type was used: Invalid type used as key in /in/vltnn on line 4 array(0) { } NULL Warning: Invalid operand type was used: Invalid type used as key in /in/vltnn on line 7 bool(false) Warning: Array key should be either a string or an integer in /in/vltnn on line 8 bool(false)
Output for 5.0.0 - 5.0.5
int(0) int(0) bool(true) bool(true) string(0) "" string(0) "" bool(true) bool(true) string(1) "0" int(0) bool(true) bool(true) float(0) int(0) bool(true) Warning: array_key_exists(): The first argument should be either a string or an integer in /in/vltnn on line 8 bool(false) bool(false) int(0) bool(true) Warning: array_key_exists(): The first argument should be either a string or an integer in /in/vltnn on line 8 bool(false) NULL string(0) "" bool(true) bool(true) Warning: Illegal offset type in /in/vltnn on line 4 array(0) { } NULL Warning: Illegal offset type in unset in /in/vltnn on line 7 bool(false) Warning: array_key_exists(): The first argument should be either a string or an integer in /in/vltnn on line 8 bool(false)
Output for 4.3.9 - 4.4.9
int(0) int(0) bool(true) bool(true) string(0) "" string(0) "" bool(true) bool(true) string(1) "0" int(0) bool(true) bool(true) float(0) int(0) bool(true) Warning: array_key_exists(): The first argument should be either a string or an integer in /in/vltnn on line 8 bool(false) bool(false) int(0) bool(true) Warning: array_key_exists(): The first argument should be either a string or an integer in /in/vltnn on line 8 bool(false) NULL string(0) "" bool(true) bool(true) Warning: Illegal offset type in /in/vltnn on line 4 array(0) { } NULL Warning: Illegal offset type in /in/vltnn on line 7 bool(false) Warning: array_key_exists(): The first argument should be either a string or an integer in /in/vltnn on line 8 bool(false)
Output for 4.3.2 - 4.3.8
int(0) int(0) bool(true) bool(true) string(0) "" string(0) "" bool(true) bool(true) string(1) "0" int(0) bool(true) bool(true) float(0) int(0) bool(true) Warning: array_key_exists(): The first argument should be either a string or an integer in /in/vltnn on line 8 bool(false) bool(false) int(0) bool(true) Warning: array_key_exists(): The first argument should be either a string or an integer in /in/vltnn on line 8 bool(false) NULL string(0) "" bool(true) bool(true) array(0) { } NULL Warning: Illegal offset type in /in/vltnn on line 7 bool(false) Warning: array_key_exists(): The first argument should be either a string or an integer in /in/vltnn on line 8 bool(false)
Output for 4.3.0 - 4.3.1
int(0) int(0) bool(true) bool(true) string(0) "" string(0) "" bool(true) bool(true) string(1) "0" int(0) bool(true) bool(true) float(0) int(0) bool(true) Warning: array_key_exists() [http://www.php.net/function.array-key-exists]: The first argument should be either a string or an integer in /in/vltnn on line 8 bool(false) bool(false) NULL bool(false) Warning: array_key_exists() [http://www.php.net/function.array-key-exists]: The first argument should be either a string or an integer in /in/vltnn on line 8 bool(false) NULL string(0) "" bool(true) bool(true) array(0) { } NULL Warning: Illegal offset type in /in/vltnn on line 7 bool(false) Warning: array_key_exists() [http://www.php.net/function.array-key-exists]: The first argument should be either a string or an integer in /in/vltnn on line 8 bool(false)