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.13, 8.1rc1 - rc3
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.26
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:
55.25 ms | 533 KiB | 12 Q