3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = [1, 5, 8]; $s = 'Hello'; $o = new stdClass(); $spl = new SplFixedArray(5); var_dump(isset($s[$o])); var_dump(empty($s[$o])); try { $s[$o] = 'A'; } catch (\Throwable $e) { echo $e->getMessage(), "\n"; } try { var_dump($s[$o]); } catch (\Throwable $e) { echo $e->getMessage(), "\n"; } try { var_dump(isset($a[$o])); } catch (\Throwable $e) { echo $e->getMessage(), "\n"; } try { var_dump(empty($a[$o])); } catch (\Throwable $e) { echo $e->getMessage(), "\n"; } try { $a[$o] = 'AAAAAAAAAAAAA'; } catch (\Throwable $e) { echo $e->getMessage(), "\n"; } var_dump(isset($spl[$o])); var_dump(empty($spl[$o])); try { $spl[$o] = 'AAAAAAAAAAAAA'; } catch (\Throwable $e) { echo $e->getMessage(), "\n"; }
Output for 8.3.0 - 8.3.4, 8.3.6
bool(false) bool(true) Cannot access offset of type stdClass on string Cannot access offset of type stdClass on string Cannot access offset of type stdClass in isset or empty Cannot access offset of type stdClass in isset or empty Cannot access offset of type stdClass on array Fatal error: Uncaught TypeError: Cannot access offset of type stdClass on SplFixedArray in /in/YhEYe:38 Stack trace: #0 {main} thrown in /in/YhEYe on line 38
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 bool(false) bool(true) Cannot access offset of type stdClass on string Cannot access offset of type stdClass on string Cannot access offset of type stdClass in isset or empty Cannot access offset of type stdClass in isset or empty Cannot access offset of type stdClass on array Fatal error: Uncaught TypeError: Cannot access offset of type stdClass on SplFixedArray in /in/YhEYe:38 Stack trace: #0 {main} thrown in /in/YhEYe on line 38
Process exited with code 255.
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18
bool(false) bool(true) Cannot access offset of type stdClass on string Cannot access offset of type stdClass on string Illegal offset type in isset or empty Illegal offset type in isset or empty Illegal offset type Fatal error: Uncaught TypeError: Illegal offset type in /in/YhEYe:38 Stack trace: #0 {main} thrown in /in/YhEYe on line 38
Process exited with code 255.
Output for 8.0.9 - 8.0.30
bool(false) bool(true) Cannot access offset of type stdClass on string Cannot access offset of type stdClass on string Illegal offset type in isset or empty Illegal offset type in isset or empty Illegal offset type bool(false) bool(true) Index invalid or out of range
Output for 8.0.0 - 8.0.8
bool(false) bool(true) Warning: Object of class stdClass could not be converted to int in /in/YhEYe on line 11 Cannot access offset of type stdClass on string Warning: Object of class stdClass could not be converted to int in /in/YhEYe on line 16 Cannot access offset of type stdClass on string Illegal offset type in isset or empty Illegal offset type in isset or empty Illegal offset type bool(false) bool(true) Index invalid or out of range
Output for 7.3.0 - 7.3.31, 7.3.33, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
bool(false) bool(true) Warning: Illegal offset type in /in/YhEYe on line 11 Notice: Object of class stdClass could not be converted to int in /in/YhEYe on line 11 Warning: Illegal offset type in /in/YhEYe on line 16 Notice: Object of class stdClass could not be converted to int in /in/YhEYe on line 16 string(1) "A" Warning: Illegal offset type in isset or empty in /in/YhEYe on line 22 bool(false) Warning: Illegal offset type in isset or empty in /in/YhEYe on line 27 bool(true) Warning: Illegal offset type in /in/YhEYe on line 32 bool(false) bool(true) Index invalid or out of range
Output for 7.3.32, 7.4.26
bool(false) bool(true) Warning: Illegal offset type in /in/YhEYe on line 11 Warning: Illegal offset type in /in/YhEYe on line 16 string(1) "A" Warning: Illegal offset type in isset or empty in /in/YhEYe on line 22 bool(false) Warning: Illegal offset type in isset or empty in /in/YhEYe on line 27 bool(true) Warning: Illegal offset type in /in/YhEYe on line 32 bool(false) bool(true) Index invalid or out of range

preferences:
144.57 ms | 402 KiB | 154 Q