3v4l.org

run code in 300+ PHP versions simultaneously
<?php $expected_array_got_string = 'somestring'; var_dump(empty($expected_array_got_string['some_key'])); var_dump(empty($expected_array_got_string[0])); var_dump(empty($expected_array_got_string['0'])); var_dump(empty($expected_array_got_string[0.5])); var_dump(empty($expected_array_got_string['0.5'])); var_dump(empty($expected_array_got_string['0 Mostel'])); echo (array)$expected_array_got_string['some_key']; echo $expected_array_got_string[0]; echo $expected_array_got_string['0']; echo $expected_array_got_string[0.6]; echo $expected_array_got_string['0.5']; echo $expected_array_got_string['0 Mostel'];
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
bool(true) bool(false) bool(false) Deprecated: Implicit conversion from float 0.5 to int loses precision in /in/7GBt1 on line 6 bool(false) bool(true) bool(true) Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /in/7GBt1:10 Stack trace: #0 {main} thrown in /in/7GBt1 on line 10
Process exited with code 255.
Output for 8.0.0 - 8.0.30
bool(true) bool(false) bool(false) bool(false) bool(true) bool(true) Fatal error: Uncaught TypeError: Cannot access offset of type string on string in /in/7GBt1:10 Stack trace: #0 {main} thrown in /in/7GBt1 on line 10
Process exited with code 255.
Output for 5.4.5 - 5.4.45, 5.5.0 - 5.5.37, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.6 - 7.2.33, 7.3.12 - 7.3.31, 7.4.0 - 7.4.33
bool(true) bool(false) bool(false) bool(false) bool(true) bool(true) Warning: Illegal string offset 'some_key' in /in/7GBt1 on line 10 Notice: Array to string conversion in /in/7GBt1 on line 10 Arrayss Notice: String offset cast occurred in /in/7GBt1 on line 13 s Warning: Illegal string offset '0.5' in /in/7GBt1 on line 14 s Notice: A non well formed numeric value encountered in /in/7GBt1 on line 15 s
Output for 7.3.32 - 7.3.33
bool(true) bool(false) bool(false) bool(false) bool(true) bool(true) Warning: Illegal string offset 'some_key' in /in/7GBt1 on line 10 Arraysss Warning: Illegal string offset '0.5' in /in/7GBt1 on line 14 ss
Output for 5.4.0 - 5.4.4
bool(true) bool(false) bool(false) bool(false) bool(true) bool(true) Warning: Illegal string offset 'some_key' in /in/7GBt1 on line 10 Notice: Array to string conversion in /in/7GBt1 on line 10 Arrayss Notice: String offset cast occured in /in/7GBt1 on line 13 s Warning: Illegal string offset '0.5' in /in/7GBt1 on line 14 s Notice: A non well formed numeric value encountered in /in/7GBt1 on line 15 s
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.3 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
bool(false) bool(false) bool(false) bool(false) bool(false) bool(false) Arraysssss
Output for 5.0.0 - 5.0.2
bool(true) bool(false) bool(true) bool(true) bool(true) bool(true) Arraysssss

preferences:
212.02 ms | 401 KiB | 349 Q