3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $foo = "test"; var_dump($foo); $foo[] = "baz"; var_dump($foo); echo("---\nSo changing a variable's type is perfectly fine, right?\n---\n"); $foo = true; var_dump($foo); $foo[] = "baz"; var_dump($foo);
based on njGRr
Output for 7.0.0 - 7.2.0
string(4) "test" Fatal error: Uncaught Error: [] operator not supported for strings in /in/4pIpn:4 Stack trace: #0 {main} thrown in /in/4pIpn on line 4
Process exited with code 255.
Output for 5.3.18 - 5.6.28
string(4) "test" Fatal error: [] operator not supported for strings in /in/4pIpn on line 4
Process exited with code 255.