3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $a = ""; $a[] = "x"; var_dump($a); $a = "x"; $a[] = "y"; var_dump($a);
Output for 7.1.0
Fatal error: Uncaught Error: [] operator not supported for strings in /in/oj9kc:4 Stack trace: #0 {main} thrown in /in/oj9kc on line 4
Process exited with code 255.
Output for 7.0.0 - 7.0.14
array(1) { [0]=> string(1) "x" } Fatal error: Uncaught Error: [] operator not supported for strings in /in/oj9kc:8 Stack trace: #0 {main} thrown in /in/oj9kc on line 8
Process exited with code 255.
Output for hhvm-3.12.0
array(1) { [0]=> string(1) "x" } Fatal error: [] operator not supported for strings in /in/oj9kc on line -1
Process exited with code 255.
Output for 4.3.2 - 5.6.28, hhvm-3.10.0
array(1) { [0]=> string(1) "x" } Fatal error: [] operator not supported for strings in /in/oj9kc on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1
array(1) { [0]=> string(1) "x" } Fatal error: [] operator not supported for strings in /in/oj9kc on line 8