3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'abc'; echo $str[TRUE]; // Notice: String offset cast occurred echo $str[NULL]; // Notice: String offset cast occurred echo $str[[]]; // Warning: Illegal offset type $int = 123; echo $int[1]; // no error echo $int[TRUE]; // no error echo $int[[]]; // no error $bool = TRUE; echo $bool[1]; // no error echo $bool[TRUE]; // no error echo $bool[[]]; // no error
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.4, 8.3.6
Warning: String offset cast occurred in /in/JCXR1 on line 5 b Warning: String offset cast occurred in /in/JCXR1 on line 6 a Fatal error: Uncaught TypeError: Cannot access offset of type array on string in /in/JCXR1:7 Stack trace: #0 {main} thrown in /in/JCXR1 on line 7
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 Warning: String offset cast occurred in /in/JCXR1 on line 5 b Warning: String offset cast occurred in /in/JCXR1 on line 6 a Fatal error: Uncaught TypeError: Cannot access offset of type array on string in /in/JCXR1:7 Stack trace: #0 {main} thrown in /in/JCXR1 on line 7
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Notice: String offset cast occurred in /in/JCXR1 on line 5 b Notice: String offset cast occurred in /in/JCXR1 on line 6 a Warning: Illegal offset type in /in/JCXR1 on line 7 a Notice: Trying to access array offset on value of type int in /in/JCXR1 on line 11 Notice: Trying to access array offset on value of type int in /in/JCXR1 on line 12 Notice: Trying to access array offset on value of type int in /in/JCXR1 on line 13 Notice: Trying to access array offset on value of type bool in /in/JCXR1 on line 17 Notice: Trying to access array offset on value of type bool in /in/JCXR1 on line 18 Notice: Trying to access array offset on value of type bool in /in/JCXR1 on line 19
Output for 7.3.32 - 7.3.33
ba Warning: Illegal offset type in /in/JCXR1 on line 7 a
Output for 5.6.0 - 5.6.23, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31
Notice: String offset cast occurred in /in/JCXR1 on line 5 b Notice: String offset cast occurred in /in/JCXR1 on line 6 a Warning: Illegal offset type in /in/JCXR1 on line 7 a

preferences:
198.48 ms | 403 KiB | 224 Q