3v4l.org

run code in 300+ PHP versions simultaneously
<?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 8.3.0 - 8.3.6
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) bool(true) bool(false) int(0) bool(true) bool(true) NULL string(0) "" bool(true) bool(true) Fatal error: Uncaught TypeError: Cannot access offset of type array on array in /in/vltnn:4 Stack trace: #0 {main} thrown in /in/vltnn on line 4
Process exited with code 255.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
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) bool(true) bool(false) int(0) bool(true) bool(true) NULL string(0) "" bool(true) bool(true) Fatal error: Uncaught TypeError: Illegal offset type in /in/vltnn:4 Stack trace: #0 {main} thrown in /in/vltnn on line 4
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
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 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.3.11, 4.4.0 - 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)

preferences:
191.05 ms | 403 KiB | 330 Q